•
•
•
•
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
![]() |
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 ?
In the Button I have
<INPUT TYPE="Button" NAME="BtnSubmit" VALUE="Submit" onKeyUp="fncWhenKeyPress(this, event)" onClick="submitForm()">
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()">
![]() |
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- enter key (VB.NET)
- KeyPress event with holding down the key (Python)
- Capture the Enter Key in an Edit Control (C++)
- please anybody help to solve keydown event for enter button problem (HTML and CSS)
- How to use two forms in asp (ASP)
- Keyboard Issue: New IE window opens when using the "L" key. (Viruses, Spyware and other Nasties)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Text selection disabled..plz help
- Next Thread: Checking for bugzilla


Linear Mode