Board Logo

UK PostCode
nodster - 6/14/2007 at 08:54 AM

Hi there,

this is a fantastic script, however is there anyway that i can change the postcode format to check for a UK postcode.

It seems to only validate postcodes in the form of ZIP code ie numerical values.

In the UK the postcode works on AB12 3CD ?

TIA

edit to add i found this reg

Code:
(GIR 0AA|[A-PR-UWYZ]([0-9]{1,2}|([A-HK-Y][0-9]|[A-HK-Y][0-9]([0-9]|[ABEHMNPRV-Y]))|[0-9][A-HJKS-UW])[0-9][ABD-HJLNP-UW-Z]{2})


how do i incorporate it into the validation script?


tigra - 6/14/2007 at 03:33 PM

Assuming this regexp is correct you can put it in the validator.js among other formats and make it embedded so you can refer it by assigned name.

example from validator.js:

'alphanum': /^w+$/,

then you use it as:

'f':'alphanum'

or you can use the regexp right in the config

'f': /^w+$/


alan5 - 9/27/2009 at 07:36 PM

To get validate UK postcodes and extended info about them you may find here: http://www.getgeocode.com/postcodes/uk/


Softcomplex: http://www.softcomplex.com/
Back to forum: http://www.softcomplex.com/forum/