Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 700
Karim Avatar asked Jan 28 '11 16:01

Karim


2 Answers

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

like image 67
andreapier Avatar answered Oct 23 '22 14:10

andreapier


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

like image 33
Ranish Karim Avatar answered Oct 23 '22 16:10

Ranish Karim