why doesn't hitting enter when a SELECT is focused submit the form?

Posted by Marc on Stack Overflow See other posts from Stack Overflow or by Marc
Published on 2010-06-03T18:25:11Z Indexed on 2010/06/03 18:44 UTC
Read the original article Hit count: 302

Filed under:
|
|
|
|

Consider the following HTML:

<form action="">
    <input />
    <select>
        <option>A</option>
        <option>B</option>
    </select>
    <input type="submit" />
</form>

If the focus is on the input (text box) and I hit enter, the form submits.

But, if the focus is on the select (dropdown box) and I hit enter, nothing happens.

I know I could figure out some JavaScript to override this, but I want to know why hitting enter doesn't just work?

Is there something I would break by capturing the enter with JavaScript (maybe some native keyboard accessibility of the dropdown)?

© Stack Overflow or respective owner

Related posts about html

Related posts about forms