Hi, I would like a script to validate the first part of a UK postcode
that separates this portion into its two parts.
I also want the script to confirm the letter(s) used is/are valid i.e.
any of: AB|AL|B|BA|BB|BD|BH|BL|BN|BR|BS|BT|CA|CB|CF|CH|CM|CO|CR|CT|CV|CW|DA|DD|DE|DG|DH|DL|DN|DT|DY|E|EC|EH|EN|EX|FK|FY|G|GL|GU|GY|HA|HD|HG|HP|HR|HS|HU|HX|IG|IM|IP|IV|JE|KA|KT|KW|KY|L|LA|LD|LE|LL|LN|LS|LU|M|ME|MK|ML|N|NE|NG|NN|NP|NR|NW|OL|OX|PA|PE|PH|PL|PO|PR|RG|RH|RM|S|SA|SE|SG|SK|SL|SM|SN|SO|SP|SR|SS|ST|SW|SY|TA|TD|TF|TN|TQ|TR|TS|TW|UB|W|WA|WC|WD|WF|WN|WR|WS|WV|YO|ZE
For example, if I keyed in SW19 (a valid first part of a post code)
The script should return SW and 19 as separate variables.
All the first parts of postcodes are in one of the following forms:
LN, LNN, LLN, LLNN, LLNL
That is to say, the first parts all begin with one or two letters and
end in N or NL. The input field in the form would have a maximum of 4
characters. It should not matter if these are entered in upper or
lower case, and incorrect matches should return false. Examples:
SW1W = True
im89 = True (even though this isn't used)
B200 = False (as there are too many digits)
Hope you get the idea. |