954,561 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Problem with Keyboard Event <Enter> Key

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 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

aparnesh
Junior Poster
194 posts since Jul 2005
Reputation Points: 20
Solved Threads: 10
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You