[ic] Formatting Zip for UK - Change to Upper Case and Add a Space??

Lyn St George lyn at zolotek.net
Thu Nov 6 19:31:53 EST 2003


On Thu, 6 Nov 2003 18:13:31 -0000, Kevin Walsh wrote:

>Andrew Smith [a_w_smith at ntlworld.com] wrote:
>> 
>> I would like to format the zip field to display correctly for UK
>> postcodes on the order_view.html page.
>>
>> UK postcodes can be of the following formats:-
>> 
>> AN NAA
>> ANN NAA
>> AANN NAA
>> 
>> Where A=Alpha and N=Numeric.
>>
>Your validation rules are incorrect.  My post code (RH9 8AX) does not
>conform to the above, neither does the BBC Broadcasting House in
>London (W1A 1AA).
>
>> 
>> At the moment all my zip/postcodes appear in lower case letters with no
>> space, even if a space is entered at checkout.
>> 
>> Is there some piece of script I could use to:-
>> 
>> 1) Convert all Alpha to uppercase
>> 2) Insert a space at the point 3 characters before the end.
>> 
>> Could this be done in Perl?
>> 
>Yes, this could be done using Perl.  I believe the following to be
>an accurate summary of the UK post code validation rules, so should
>help to get you started:
>
>  1. The total length must be 5, 6 or 7 characters, excluding the space.
>
>  2. A single space must be included in the post code.
>
>  2. The inward code, the part to the right of the space, must always
>     be 3 characters.
>
>  3. The first character of the inward code must be numeric.
>
>  4. The second and third characters of the inward code must be alpha.

Usually, but not always true, eg WC1 or EC3 in London. 

>  5. The outward code, the part to the left of the space, can be 2, 3
>     or 4 characters.
>
>  6. The first character of the outward code must be alpha.
>
>-- 
>   _/   _/  _/_/_/_/  _/    _/  _/_/_/  _/    _/
>  _/_/_/   _/_/      _/    _/    _/    _/_/  _/   K e v i n   W a l s h
> _/ _/    _/          _/ _/     _/    _/  _/_/    kevin at cursor.biz
>_/   _/  _/_/_/_/      _/    _/_/_/  _/    _/

-
Cheers
Lyn St George
+---------------------------------------------------------------------------------
+ http://www.zolotek.net .. eCommerce hosting, consulting
+----------------------------------------------------------------------------------



More information about the interchange-users mailing list