i am submitting a form in javascript and i want it to submit on key press submit, but it wont work. here is my code:
<script type='text/javascript'>
function login(evt){
if (evt){var keyCode = evt.which ? evt.which : evt.keyCode;}else{keyCode='';}
if ((evt == '')||(keyCode == 13)){
if (document.forms["login"].email.value=='')
{
alert('You must enter an email to login!');
}else if (document.forms["login"].password.value=='')
{
alert('You must enter a password to login!');
}else{
document.forms["login"].submit();
}return false;}}
</script>
<form name='login' method='post'>
<tr><td class=status>User: <input type='text' name='email' class='login' id='email' OnKeyDown="return login(event);" style='margin-bottom: 2px;margin-top: 0px; '></td></tr>
<tr><td class=status style='padding-right: 3px;'>Pass: <input type='password' name='password' class='login' OnKeyDown="return login(event);" id='password' style='margin-bottom: 1px; margin-top: 0;'></td></tr>
<tr><td style='padding-right: 3px;'><a href="javascript: login(''); return false" class='loginbutton'>Login</a></td></tr>
</form>