I'm trying to validate a <form>
with JavaScript, but the code I've created is not doing anything. seems to me correct.
HTML code
<form name="ContactForm" action="addDataAdmin.php" method="POST" enctype="multipart/form-data" autocomplete="off" onsubmit="return ValidateContactForm();">
<p>ISBN</p> <input type="text" name="ISBN">
<p>Author's Name</p> <input type="text" name="Authorsname">
<p>Title</p> <input type="text" name="Title">
<p>Edition</p> <input type="text" name="edition">
<p>Year</p> <input type="text" name="year">
<p>Category</p>
<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 />
<p>Publisher</p> <input type="text" name="publisher">
<p>Quantity-in-stock</p> <input type="text" name="quantityinstock">
<p>Price</p> <input type="text" 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>
Script
function ValidateContactForm()
{
var ISBN = document.ContactForm.ISBN;
var Authorsname = document.ContactForm.Authorsname;
var Title = document.ContactForm.Title;
var edition = document.ContactForm.edition;
var year= document.ContactForm.year;
var category = document.ContactForm.category;
var publisher = document.ContactForm.publisher;
var quantityinstock= document.ContactForm.quantityinstock;
var price = document.ContactForm.price;
}
if (ISBN.value == "")
{
window.alert("Please enter ISBN.");
ISBN.focus();
return false;
}