Upon clicking submit, the function doesn't seem to get called and the form submits even if the return is false.
function validateForm() {
if (document.getElementById("nm").value="") {
alert("You must enter a name!");
return false;
}
if (document.getElementById("em").value="") {
alert("email required");
return false;
}
return true;
}
And the HTML:
<form onsubmit=" return validateForm();" action="myscript.php" id="primary">
<label>Name<input type="text" id="nm"></input></label>
<label>Email<input type="text" id="em"></input></label>
<input type="submit" id="send" value="submit"></input>
</form>