html regular button is triggered with an enter key

M

Matt

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');">
 
J

Jukka K. Korpela

I want html regular button is triggered with an enter key.

Is "html regular button" the kind of a button that you can find
in the shirts of (alt.)html regulars? If not, what is it?
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.

It's very difficult to see what you are really getting at, since you
describe the issue in vague terms and don't post a URL.
<INPUT TYPE="button" value="regular button"
onClick="alert('button');"> <INPUT TYPE="submit" value="submit
button" onClick="alert('submit');">

This isn't all, is it? Are you referring to hitting Enter when focused on
a button, or when focused on a text field somewhere?

But it would be best to start from the beginning. Why are you using
<input type="button">? It's almost always a mistake. It's better to use
<input type="submit">, because then you can arrange a server-side backup
functionality for situations where JavaScript is disabled or filtered
out.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,252
Latest member
MeredithPl

Latest Threads

Top