on 17/2/04 12:14 pm, Ford, Mike [LSS] at [EMAIL PROTECTED] wrote:
> On 17 February 2004 10:43, Roddie Grant wrote: > >> on 17/2/04 10:25 am, Shaun at [EMAIL PROTECTED] 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 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php