This code is used for zip code validation. Here, regular expression is used to validate the pin code.
<script type='text/javascript'>
function validate(zipcode)
{
var regpincode = /^([1-9])([0-9]){5}$/;
if(regpincode.test(zipcode) == false)
{
$("#status").html("Postcode is not yet valid.");
}
else
{
$("#status").html("Your Postal Index Number is valid!");
}
}
</script>
<div style='text-align: center;'>
<div id="status">Please enter a valid postcode.</div>
<input type="text" name="postcode" onkeyup="validate(this.value);">
</div>