Re: UK Postcodes Format

From: Date: Tue, 17 Feb 2004 12:44:34 +0000
Subject: Re: UK Postcodes Format
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-177934@lists.php.net to get a copy of this message
on 17/2/04 12:14 pm, Ford, Mike [LSS] at M.Ford@leedsmet.ac.uk wrote: > On 17 February 2004 10:43, Roddie Grant wrote: > >> on 17/2/04 10:25 am, Shaun at shaun@mania.plus.com wrote: >> >>> Hi, >>> >>> does anyone know the format of the postcodes in the UK so I can >>> keep my database accurate? >>> >>> Thanks >> >> >> Try >> http://javascript.internet.com/forms/uk-postcode-validation.html > > Wow, at a glance I'd say that looks like pretty crappy JavaScript, and also > not a totally accurate UK postcode checker. > > The only guaranteed way to fully validate a UK postcode is to purchase the > Royal Mail's Postcode Address File (PAF) (and subscribe to its updates!), but > you can validate the format fairly closely with some simple rules. > > For example, here's a regexp that matches valid UK postcode patterns: > > /[A-Z]{1,2}[0-9][0-9A-Z]? [0-9][ABD-HJLNP-UW-Z]{1,2}/ <snip> Hmm, I hadn't actually looked at the JavaScript - just at the description of how postcodes are structured. But the link to the Royal Mail site is much better for that. <sigh /> If only Royal Mail had remembered programmers when they thought up the postcode system. Mike, I'm very impressed with your knowledge of postcodes! Even better than the Royal Mail site. Roddie Grant roddie@myword.co.uk

« previous php.general (#177934) next »