RickardP_GSI
asked on
Javascript number and length validation
This is validation for the length of the input number but i need to validate that the actual input is in fact a number with no letters
if (document.login.userID.value == "" || document.login.userID.value.length != 6) {
alert("Please enter your 6-digit Employee ID to begin your training.")
document.login.userID.focus();
return false;
}
ASKER
there is more to it - here is the URL: http://uploads.guestservices.com/CASH_HANDLING/Cashier/index.htm
there is more to itCan you elaborate?
ASKER
I mean there is more javascript in the file. If you look at line 103 you will see where it starts - http://uploads.guestservices.com/CASH_HANDLING/Cashier/index.htm
I must be missing something, but I don't see an issue. Just include what I suggest above as the first if clause.
e.g.
e.g.
function saveLoginName() {
RegExp reg = new RegExp("^[0-9]{6}$");
if (!reg.test(document.login.userID.value)) {
alert("Please enter your 6-digit Employee ID to begin your training.")
document.login.userID.focus();
return false;
} else if(document.login.userFirst.value == "" || document.login.userFirst.value == "") {
alert("Your full first name must be entered");
document.login.userFirst.focus()
return false
} else if(document.login.userLast.value == "" || document.login.userLast.value == "") {
alert("Your last name must be entered");
document.login.userLast.focus()
return false
}
setCookie("userName", document.login.userID.value)
setCookie("userFirst", document.login.userFirst.value)
setCookie("userLast", document.login.userLast.value)
setCookie("studn", document.login.userID.value)
document.login.submit()
}
ASKER
It tells me I have a syntax error when I put your code in
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ahhhhhhhhhhh PERFECT - thank you so much!!
e.g.
Open in new window
The pattern means:
Open in new window