UK Zip Code Validation

UK Zip Code Validation is use to validate a UK zip or posatl code at here.

Demo :



  Validate UK zip :    

Example :

Just type a UK zip code at text box like this NW3 5ED and click check button Is a properly-formatted UK postcode message will display otherwise type a 56456 number at textbox and click check button Is an improperly-formatted UK postcode will display here.

Code :

Following code is use to UK Zip Code Validation Script if you need to copy and use to your website.


<?php
  function validateUKZip($str)
  {
    return eregi("^[a-z]{1,2}[0-9]{1,2}([a-z])?[[:space:]]?[0-9][a-z]{2}$" ,$str);
  }
    $uk_postal = "NW3 5ED";
    echo validateUKZip($uk_postal) ? "Is a properly-formatted UK postcode" : "Is an improperly-formatted UK postcode";
?>

In the above $uk_postal variable is use to assign the zip code number. In the validateUKZip() function is use to check the validate zip code number through regular expression.

Free Download Script :

If you need to uk zip code validation script click and download from following link.

Download




Content