Validating uk postcodes

If you don't have access to the PAF, you can at least check that the postcodes in your application follow these rules.In this article, we offer a VFP function that does just that.The only practical way to access it is by purchasing specialised address management software, and this is inevitably an expensive option.

Validating uk postcodes

(But even that wouldn't be a perfect check, as the PAF is never completely up to date, postcodes are constantly being added, and existing premises are occasionally re-coded.

Also, Royal Mail acknowledges that the PAF contains errors.) function check Post Code (to Check) { var alpha1 = "[abcdefghijklmnoprstuwyz]"; var alpha2 = "[abcdefghklmnopqrstuvwxy]"; var alpha3 = "[abcdefghjkpmnrstuvwxy]"; var alpha4 = "[abehmnprvwxy]"; var alpha5 = "[abdefghjlnpqrstuwxyz]"; var pcexp = new Array (); (new Reg Exp ("^(" alpha1 "" alpha2 "?

It's easy enough to add a filter to remove the space, but I'm a little worried that when (and if) it gets fixed, will the fixed version Zend_Validate_Post Code then fail to validate postcodes without the space?

In theory it should as the space is part of the spec.

The functions also take into account which letters are valid in the various positions.

If the parameter is a valid postcode, the function returns it correctly formatted - i.e.

This ex is for email verification, you just need to replace str Regex value and need to pass your textbox value to the method.

These functions check the validity of a UK postcode specified by the supplied parameter. The definition of a valid postcode has been taken from the official specification, and from the list of BFPO codes.

In this article, we offer a Javascript function that does just that.

Tags: , ,