User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 427,122 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,098 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 2958 | Replies: 0
Reply
Join Date: Jul 2005
Posts: 169
Reputation: aparnesh is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 10
aparnesh's Avatar
aparnesh aparnesh is offline Offline
Junior Poster

Question Problem with Keyboard Event <Enter> Key

  #1  
Dec 28th, 2006
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()">
AddThis Social Bookmark Button
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JavaScript / DHTML / AJAX Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 6:23 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC