A form that does not submit when there is more than one input

This is a pretty simple problem to describe. This has been tested on Firefox (3.6), IE (8) and Chrome (8).

Here is the donotsubmit.html file

<form> <input /> <input /> </form> 

When the focus is on one of the inputs and you press the enter button, nothing happens.

Below is the doessubmit.html file

 <form> <input /> </form> 

When the focus is at the input and you press enter, the form is submitted.

Any understanding of this inconsistent behavior?

I know that there is no submit button on the form, and therefore it is not semantically correct. In any case, the sending process should have been automatically processed using the jQuery dialogs button buttons, and I would not know how to place an additional <input type = "submit" />.

+6
input submit forms keypress enter
source share
2 answers

user754151 is correct. This is a known bug, but I assume that you can get rid of it just by intercepting the keypress input event.

+1
source share

There are two possible solutions to this problem.

  • The simplest solution is to add another 1 input field that the user will not see.

  • you can bind the keydown event of this input field, and in this function just check keyCode == 13 then preventDefault ().

+1
source share

All Articles