I'm trying to validate a form. I want the value entered into the textbox, Patron ID, to be greater than 20000000 and less than 21999999. I also want it to contain only numbers. Following is the code I'm working with.
function validate() {
if (document.PurchaseRequest.PatronID.value < 20000000 || document.PurchaseRequest.PatronID.value > 21999999) {
window.alert("Please enter a valid Patron ID.");
return false;
else {
if ((document.PurchaseRequest.PatronID.value / document.PurchaseRequest.PatronID.value) != 1) {
window.alert("Please enter a valid Patron ID.");
return false;
}
}
return true;
}
If I test the two condtions separately, they work, but when I combine them, they don't. Is it the way I'm using the else/if?
Any help is appreciated.
function validate() {
if (document.PurchaseRequest.PatronID.value < 20000000 || document.PurchaseRequest.PatronID.value > 21999999) {
window.alert("Please enter a valid Patron ID.");
return false;
else {
if ((document.PurchaseRequest.PatronID.value / document.PurchaseRequest.PatronID.value) != 1) {
window.alert("Please enter a valid Patron ID.");
return false;
}
}
return true;
}
If I test the two condtions separately, they work, but when I combine them, they don't. Is it the way I'm using the else/if?
Any help is appreciated.