Single text box and submit behaviour

html, javascript

Solution

HTML 2.0 Specs:

When there is only one single-line text input field in a form, the user agent should accept Enter in that field as a request to submit the form.

The easiest way to disable this behavior is to add a hidden input field.

Problem

I have a single text box with no submit button on form as below : ``` <html> <form action="http://www.google.com"> <input type="text"/> </form> </html> ``` when text box is selected and i press enter key form will get submitted and google page will be displayed. however if i have two text box as bellow : ``` <html> <form action="http://www.google.com"> <input type="text"/> <input type="text"/> </form> </html> ``` now if i press submit button nothing will happen. Can anyone explain here : i) why form is get submitted in first case? ii) why form is not submitting in second case?

Original source