I'm trying to validate a form. the user can only instroduz numerals values. I did the following but it is not working
function ValidateContactForm()
{
var year = document.ContactForm.year;
if (year.value == "")
{
isNaN( document.myForm.edition.value)
window.alert("Please enter year.");
year.focus();
return false;
}
}
HTML code
<body>
<?php include 'addDataAdmin.php';?>
<form name="ContactForm" action="addDataAdmin.php" method="POST" enctype="multipart/form-data" autocomplete="off" onsubmit="return ValidateContactForm();">
ISBN:<input type="text" name="ISBN">
Author's Name:<input type="text" name="Authorsname">
Title:<input type="text" name="Title">
Edition:<input type="number" name="edition">
Year:<input type="number" name="year">
Category:
<select name="category" size="1">
<option value="computing">Computing</option>
<option value="Romance">Romance</option>
<option value="Fiction">Fiction</option>
<option value="Non-Fiction">Non-Fiction</option>
</select>
<br />
Publisher:<input type="text" name="publisher">
Quantity-in-stock:<input type="number" name="quantityinstock">
Price:<input type="number" name="price">
<input type="file" name="fileToUpload" id="fileToUpload">
<input type="submit" value="Upload Image" name="submit" formaction="/upload.php">
<input type="submit" value="Send" name="send">
<input type="reset" value="Clear">
</form>
</body>
</html>