Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to use the enter key to link

 
sanjib kumar mandal
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>

</tr>

Thanks and regards
sanjeev
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34095
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sanjeev,
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.
 
Pratik Lohia
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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;
validate(textValue)

}else
{
return false;
}

}

html:text name="xyzeeform" property="password"
styleClass="medium" maxlength="18" ON KEY PRESS="enterPressed()"
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic