GeeCON Prague 2014*
The moose likes HTML, CSS and JavaScript and the fly likes submit a form when you hit 'enter' 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 "submit a form when you hit Watch "submit a form when you hit New topic
Author

submit a form when you hit 'enter'

Chitra Jay
Ranch Hand

Joined: May 02, 2002
Posts: 76
Hi,
How do I make a form submit the values upon hitting enter in the textbox?
In the webpage, there are 2 textfields username & password and a go button (which is a actually an image).
when the user hits 'enter' on the password field, the form should submit values.
Code Snippet:
<form action="/Online/logon.aspx" name="thisForm" id="thisForm" method="post">
<td><img src="pix/user_name.gif" alt="Username" width="49" height="25" border="0"></td>
<td width="80"><input tabindex="1" type="text" name="username" value="" size="10"></td>

<td><img src="pix/password.gif" alt="Password" width="49" height="25" border="0"></td>
<td width="80"><input tabindex="2" type="password" name="password" size="10"></td>

<td width="25"><a href="/Online/logon.aspx" onKlick="document.thisForm.submit(); return false;" tabindex="3">
<td><img src="pix/go.gif" alt="Go" width="25" height="17" border="0"></a></td>
</form>

Thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61318
    
  66

How do I make a form submit the values upon hitting enter in the textbox?


Make sure that the form has a submit button.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Nila dhan
Ranch Hand

Joined: Sep 15, 2005
Posts: 160
try this

<input type="image" value="submit">
Chitra Jay
Ranch Hand

Joined: May 02, 2002
Posts: 76
thanks!! that worked
 
GeeCON Prague 2014
 
subject: submit a form when you hit 'enter'