Karim
Karim

Reputation: 71

Form not submitting when there is more than one input text

This is a quite simple issue to describe. This was tested on Firefox (3.6), IE (8) and Chrome (8).

Here is the file doesnotsubmit.html

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

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

Below is the file doessubmit.html

<form>
    <input />
</form>

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

Any insight on this inconsistent behavior ?

I know the form lacks a submit button, and thus is not semantically correct. Anyway, the submit process was meant to automatically be handled through jQuery dialogs buttonpane's buttons, and I wouldn't know how to place an additional <input type="submit" />.

Upvotes: 7

Views: 759

Answers (2)

Ranish Karim
Ranish Karim

Reputation: 366

There are two possible solution for this issue.

  1. The simplest solution is to add 1 more input field which will not visible to user.

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

Upvotes: 1

andreapier
andreapier

Reputation: 2958

user754151 is correct. This is a known bug but i guess you can get rid of it just intercepting the enter keypress event.

Upvotes: 1

Related Questions