File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes How to use the enter key to link Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "How to use the enter key to link" Watch "How to use the enter key to link" New topic

How to use the enter key to link

sanjib kumar mandal

Joined: Jul 20, 2005
Posts: 8
Hi All,
I have jsp page called login.jsp where the user can input his userID and Password and a signIn link is given.The user can move the cursor from userId to password by using the tab key and user can also move to the signIn link by using the tab key and then user have to use the enter key to go to the next page.But my problem is if i enter the password after entered the userid and do not use tab key instead use the enter key the control is not going to the signIn link.

Please help me to solve the problem.
The part of code that i have used in jsp page is given below:

<tr class="whitebg">
<td height="25" valign="middle" ><a href="javaScript:goTologinAction()" class="btnlink">Sign in </a></td>


Thanks and regards
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33119

You really have a form on that page even though you are using a link for the submission. You can add onSubmit to the form's action and have it call the JavaScript function.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Pratik Lohia
Ranch Hand

Joined: May 05, 2005
Posts: 88
For the password text box, on the event onkeypress, call a method to check wat key has been pressed, and if the key code is 13, you kknow that the enter key is pressed, and then you perform watever action you want.

The sample code,

function enterPressed(){

if (window.event.keyCode==13){
var textValue=document.forms[0].password.value;

return false;


html:text name="xyzeeform" property="password"
styleClass="medium" maxlength="18" ON KEY PRESS="enterPressed()"
I agree. Here's the link:
subject: How to use the enter key to link
jQuery in Action, 3rd edition