I have a function that I intend to use for validating zip codes and I wanted to know if my way could be made better.
function zipcode (inputtxt)
{
var zipcode = /^\+?([0-9]{2})\)?[-. ]?([0-9]{4})[-. ]?([0-9]{4})$/;
if((inputtxt.value.match(zipcode))
{
return true;
}
else
{
alert("message");
return false;
}
}