I have a login screen in which the user has to specify the User Name and Password. There is a submit button which accepts the values and passes to the server for authentication. I would like to allow the user to use the <Enter> key in the password field to submit the values. I copied the keyboard event handler code from a Javascript book ( I am quite new to all this), but it is giving a syntax error. I checked several times with the book for a typo, but found none. Could you please tell me what's wrong with this code ?
function isEnterKey(evt)
{
evt = (evt) ? evt : (window.event) ? window.event : "";
var theKey ;
if (evt)
{
theKey = (evt.which) ? evt.which : evt.keyCode ;
}
return (theKey == 13);
}
function fncWhenKeyPress(fld, evt)
{
if (isEnterKey(evt))
{
document.Form1.submit();
return true;
}
else
return false ;
}
In the Button I have
<INPUT TYPE="Button" NAME="BtnSubmit" VALUE="Submit" onKeyUp="fncWhenKeyPress(this, event)" onClick="submitForm()">