Do not use code, components or techniques unless you are satisfied that they will work correctly in your applications.
This isn’t usually too taxing, especially with browsers providing auto-complete these days, but one quirk of many of these pages that I find disproportionately irritating is the appalling and inconsistent rules they apply to postcodes.
The official postcode specification details the structure of the postcode, and there is also a list of BFPO numbers from In this article, we offer a Javascript function that does just that.
The map below shows the areas defined by the postcode area, postcode district, postcode sector and unit postcode for example postcode WC2B 4AB: The approach for parsing a postcode varies in complexity depending on two things: If you are familiar with other languages, and would like to contribute a method in another language, we would love to hear from you on Twitter or by email.
In this article, we offer a PHP function that does just that.[0-9])(\s*)([0-9]" alpha5 ")$","i")); (new Reg Exp ("^(" alpha1 "[0-9]" alpha3 ")(\s*)([0-9]" alpha5 ")$","i")); (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.(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.
Remember, postcode validation function below only checks that the code is in the correct format.