JavaScript Function for international Zip Code Validation

JavaScript Function for international Zip Code Validation

During we write an address you must notice Pin code is there. According to postal Pin code make easy to reach the address. Are you in your Contact us page? Looking something like which can validate a pin code entered by the user. In the below function I had implemented Zip code validation using JavaScript. You can implement the same logic in any language.

The Control here I used to take input from user is txt_zip. In-case you copy the below code. Update this with your Control Name. The logic I implemented here is so Simple. Using indexOf I am checking all the characters in txt_zip value.

Zip Code Validation Function

function zipcode_org(source,arguments)
{
var ValidChars = "0123456789";
var Char;
var sText=document.getElementById("txt_zip").value;
for (i = 0; i < sText.length; i++)
{
Char = sText.charAt(i);
if (ValidChars.indexOf(Char) == -1)
{
arguments.IsValid = false;
return;
}
}
return;
}