UK Postcode Validation | JavaScriptSource

UK Postcode Validation

Peter Haydon Sep 24, 2001
Checks that postcodes are in correct format. Is written for UK format, but is easily adapted for other countries.

UK Postcode Format Validation

Postcodes must conform to the following rules:-

  1. The total length must be 6,7, or 8 characters, a gap (space character) must be included
  2. The inward code, the part to the right of the gap, must always be 3 characters
  3. The first character of the inward code must be numeric
  4. The second and third characters of the inward code must be alpha
  5. The outward code, the part to the left of the gap, can be 2,3, or 4 characters
  6. The first character of the outward code must be alpha

Note: There are over 1.7 million UK postcodes, and that number grows daily. This page cannot guarantee that a particular code is valid, it only checks that the format is correct.

The JavaScript Source: Forms: UK Postcode Validation

Simply click inside the window below, use your cursor to highlight the script, and copy (type Control-c or Apple-c) the script into a new file in your text editor (such as Note Pad or Simple Text) and save (Control-s or Command-s). The script is yours!!!


Did you use this script?  Do you like this site?  Please link to us!

Leave a Response