By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,930 Members | 1,323 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,930 IT Pros & Developers. It's quick & easy.

html regular button is triggered with an enter key

P: n/a
I want html regular button is triggered with an enter key. That means, when the user
press ENTER key, it will trigger the event in html regular button. I tried
the following code, and I realized submit button is triggered with an
enter key. But not html regular button. Any workarounds? Please advise. Thanks!!

<INPUT TYPE="button" value="regular button" onClick="alert('button');">
<INPUT TYPE="submit" value="submit button" onClick="alert('submit');">
Jul 23 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Matt wrote on 27 aug 2004 in comp.lang.javascript:
I want html regular button is triggered with an enter key. That means,
when the user press ENTER key, it will trigger the event in html
regular button. I tried the following code, and I realized submit
button is triggered with an enter key. But not html regular button.
Any workarounds? Please advise. Thanks!!

<INPUT TYPE="button" value="regular button"
onClick="alert('button');"> <INPUT TYPE="submit" value="submit button"
onClick="alert('submit');">


Its all in a name.
<INPUT TYPE="submit" value="regular button"
onClick="alert('button');">

<INPUT TYPE="button" value="submit button"
onClick="alert('submit');return false;">
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 23 '05 #2

P: n/a
>
<INPUT TYPE="submit" value="regular button"
onClick="alert('button');">

<INPUT TYPE="button" value="submit button"
onClick="alert('submit');return false;">


I added return false in regular button, but when i press enter key, it
still triggers submit button
Jul 23 '05 #3

P: n/a
Matt wrote on 28 aug 2004 in comp.lang.javascript:

<INPUT TYPE="submit" value="regular button"
onClick="alert('button');">

<INPUT TYPE="button" value="submit button"
onClick="alert('submit');return false;">


I added return false in regular button, but when i press enter key, it
still triggers submit button


A button never [well, without a lot of scripting] reacts to an enter key.
A selected <input type=text> enter key submits a form, but does not trigger
a button.

Show your exact code, please, including the <form> and the other <input>s.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress,
but let us keep the discussions in the newsgroup)

Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.