J
jimmygoogle
I am checking user input in a form and they should ennter only the
last 4 digits of their account number. My code catches it if they
enter 3 but it thinks it ok if they enter 5. How can I have it fail
for 5 numbers?
function checkAccount(account) {
var regexp = /\d{4}/;
if (!regexp.test(account)){
alert ('Please enter the last 4 digits of your account number.');
return false;
}
else{
return true;
}
}
last 4 digits of their account number. My code catches it if they
enter 3 but it thinks it ok if they enter 5. How can I have it fail
for 5 numbers?
function checkAccount(account) {
var regexp = /\d{4}/;
if (!regexp.test(account)){
alert ('Please enter the last 4 digits of your account number.');
return false;
}
else{
return true;
}
}