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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Submit button, onClick and enter key

Status
Not open for further replies.

awingnut

Programmer
Feb 24, 2003
759
US
I have a form with an onClick event (javascript) for the submit button. When the button is clicked it works fine. However, when the enter key is pressed, the form is submitted but the javascript is not executed. Is this the way it is supposed to work? If so, what do I need to do to get the enter key to run the javascript as well? TIA.
 
Please ask Javascript questions in forum216: Javascript.

<marc>
 
This seems to me like an HTML form question about the behavior of the enter key but I'll try there.
 
Although I agree that this is really a javascript question, as a start try putting the function in the form's onsubmit event rather than the button's onclick event.

--James
 
This turned out to be an HTML question after all, as I suspected. While the onSubmit suggestion was a correct one it did not answer the underlying problem (which I did not properly ask because I did not know what it was). What I did not realize, and learned, is that the enter key will not do a submit if the current focus is in a radio, checkbox or no field. For the enter key to do a submit, it must be in a text field (and possibly a list field but I did not test that).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top