Home } Forms } UK Postcode Validation



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
Postcode:

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!

Add a comment, suggestion, or correction
[For questions about usage, consult the Notes tab above or visit the JavaScript forum. Do not include more than two (2) lines of code in your comments. If you have suggestions or corrections, you can submit them to us.]

    
   
       
[optional]
 
[optional]

   

Comments feed Comment Feed RSS 2.0

Sign up for the JavaScript Weekly

internet.com Privacy Policy
We'll send this script to you!

(just click "Send it!" once!)