Validating postcodes

The function is not only for validating the issue of having alpha and numeric on the rigth spot, but also having the right kind of alpha and numeric on the right spot. I didn't realise until I looked more deeply that Q, V and X weren't allowed in the first position, I, J and Z weren't allowed int he 2nd position and the letters in the 3rd position were as you specified.This is the best and most comprehensive postcode validator that I have seen. The digits specify the district within the area, typically with 1 indicating the centre of a city and moving outwards.There’s also an additional complication in London (and perhaps other densely populated areas) that the district becomes too large for use, so an additional letter may be appended to the end of the outward code to further subdivide it.Validating a postcode is a case of checking that the postcode is in the correct format, e.g. The best library I have found for this is Braemoor Software’s Postcodes Validation Script, which contains PHP and Java Script code so you can validate on the client side and the server side.Verification is the process by which you check whether a postcode actually exists.

validating postcodes-41validating postcodes-86

Most countries have postal codes of some sort — America has postcodes (I can’t speak for the others).In the UK, postcodes are a crucial part of someone's address, as they narrow addresses down to the street of the desired location (in countries like France, however, a postcode only tells you which city or town the address is located).It can be handy to make sure your users provide a valid UK postcode in a form.SELECT @b Valid = 1 WHERE @str Post Code LIKE '[A-Za-z][A-Za-z][0-9][0-9][0-9][A-Za-z][A-Za-z]'OR @str Post Code LIKE '[A-Za-z][A-Za-z][0-9][A-Za-z][0-9][A-Za-z][A-Za-z]'OR @str Post Code LIKE '[A-Za-z][0-9][0-9][0-9][A-Za-z][A-Za-z]'OR @str Post Code LIKE '[A-Za-z][A-Za-z][0-9][0-9][A-Za-z][A-Za-z]'OR @str Post Code LIKE '[A-Za-z][0-9][0-9][A-Za-z][A-Za-z]'OR @str Post Code LIKE '[A-Za-z][A-Za-z][0-9][0-9]'OR @str Post Code LIKE '[A-Za-z][0-9][0-9]' Really?XX123YY will pass your first line of WHERE but it is not a VALID postcode.