Form not submitting when there is more than one input text
Asked Answered
A

2

7

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" />.

Asir answered 28/1, 2011 at 16:12 Comment(2)
If I had to guess I would say "not submitting" was desired behavior, but they added an exception to a form with one input for the sake of websites with search fields (which this is their typical pattern). Though I'm really on speculating here...Idaliaidalina
Well the insight is here, see the link to the HTML SpecDarned
T
1

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

Transept answered 23/12, 2011 at 14:7 Comment(0)
C
1

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().

Couture answered 4/3, 2016 at 11:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.