Vote count:
0
I need a form field that if a number under 21 and over 35 is entered there is a pop up up that tells them to enter a number between 21 and 35.
Firstly I have seen this one, it doesn't solve my requirements:
Form validation with Javascript - Field value must be between 2 specific numbers
I have the following and it doesn't work, any idea why?
<!DOCTYPE html>
<html>
<head>
<script>
function validateForm() {
var x = document.forms["daysCalc"]["days"].value;
if (x>=21 && x<=35) {
alert("Number must be between 21 and 35");
return false;
}
}
</script>
</head>
<body>
<form name="daysCalc" action="" onsubmit="return validateForm()" method="post">
Days: <input type="text" name="days">
<input type="submit" value="Submit">
</form>
</body>
</html>
Your help would be appreciated.
Thanks in advance
asked 11 secs ago
Javascript Form Validation Between 2 Numbers
Aucun commentaire:
Enregistrer un commentaire