Thursday 19 September 2013

validation alert message for zip code

validation alert message for zip code

Hi I am not getting my alert message correctly and my code is:
function isNumberKey( event ) {
var charCode = (event.which)? event.which: event.keyCode;
var ctrl = event.ctrlKey;
var shift1=event.shiftKey;
var zipcode=document.getElementById(zipCode).value;
if ( ctrl ) {
return true;
}
if ( ( charCode >= 95 && charCode <= 105) || (charCode >= 106 &&
charCode <= 123 ) ) {
return true;
}
if ( charCode == 36 || charCode == 35 || charCode == 45 || charCode ==
46 || charCode == 144 || charCode == 145 ) {
return true;
}
if ( charCode >= 106 && charCode <= 123 ) {
return true;
}
if ( ( shift1 ) || charCode > 41 && (charCode < 48 || charCode > 57 ) ) {
alert("The ZIP Code entered is invalid. Please enter a 5 digit ZIP
Code.");
return true;
}
}
can anyone help for this ?

No comments:

Post a Comment