For some reason my JavaScript won't validate my forms and I cannot work out why. I've followed examples from many sites like Tizag & W3C, but to no avail.
HTML form:
<form class='login' name='login' onsubmit='return loginValidation();' method='post' action='index.php'>
<p>
<input class='login' type='text' name='nameentry'/><br/>
<input class='login' type='submit' value='Login'/>
</p>
</form>
JavaScript function:
function loginValidation(){
var x=document.form.login.nameentry.value;
if(x==null || x==""){
alert("Enter a name");
return false;
}
}
My code can be seen in action here [an assignment]. Any ideas?