Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Enter Key: Event Handler on Login Screen

Status
Not open for further replies.

SmileyFace

Programmer
Sep 10, 2002
99
US
I need to know how to make a form submit information by just pressing the enter button without clicking on the button itself. I don't think I can use input type = 'submit' in this form to do that.

Its a login screen...heres the code....please help

<form name=&quot;frmLogin&quot; action=&quot;loginaction.asp&quot; method=&quot;post&quot;>

<br><br><br>
<table border=&quot;1&quot; bgcolor=&quot;#0F7195&quot; rules=&quot;none&quot; cellpadding=&quot;2&quot;>
<tr>
<td align=&quot;center&quot;>
<img src=&quot;images/ineosloginheader.jpg&quot; border=&quot;0&quot;>
</td>
</tr>
<tr>
<td align=&quot;center&quot;>
<img src=&quot;images/username.jpg&quot; border=&quot;0&quot;><input type=&quot;text&quot; name=&quot;txtUserName&quot; size=&quot;25&quot;>
</td>
</tr>
<tr>
<td align=&quot;center&quot;>
<img src=&quot;images/password.jpg&quot; border=&quot;0&quot;><input type=&quot;password&quot; name=&quot;txtPassword&quot; size=&quot;25&quot;>
</td>
</tr>
<tr>
<td align=&quot;center&quot;><img src=&quot;/images/blank.gif&quot; border=&quot;0&quot; height=&quot;1&quot; width=&quot;1&quot;></td>
</tr>
<tr>
<td align=&quot;center&quot;>
<a href=&quot;javascript:document.forms(0).submit()&quot;><img src=&quot;images/login_ok.jpg&quot; border=&quot;0&quot; width=&quot;60&quot; height=&quot;19&quot;></a>
<a href=&quot;javascript:document.forms(0).reset()&quot;><img src=&quot;images/login_reset.jpg&quot; border=&quot;0&quot; width=&quot;60&quot; height=&quot;19&quot;></a>
</td>
</tr>
</table>
</form>

</center>

</body>
</html>
 
If you are typing in a type=text and press enter, the form is automatically submitted (at least in my IE 6 browser). If you need to set the focus so that the user is typing in the box do this:

<body onLoad=&quot;document.frmLogin.txtUserName.focus();&quot;>

Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top