Aberrant behavior with single-input forms in IE7
Posted on April 14, 2009 at 9:02 am
These examples show the difference in handling form submissions between Internet Explorer (version 7 tested) and probably any competent browser on the web (read: everything else). Never mind the fact that this sort of browser behavior is contrary to everything you’d expect. Hope this saves someone the three hours it wasted for me.
Submitted form data
$_POST Array ( )
Apparently this is wrong
This form has two inputs; a text input named “text” and a submit input named “submit”. Pressing enter while the text field has focus submits the form, but only the text field — the submit button is left behind. If you click the submit button, both fields are properly submitted.
You’d think this would work
Apparently this fantastic bug stems from single-input forms, although there doesn’t really seem to be a lot more information than that on the topic. A logical human, when confronted with this altogether idiotic fact, would attempt to do something like add another input field.
This form is identical to the one above, only with the addition of a hidden field “extra” with a blank value. Pressing enter while in the text field acts similar to above, in that both “extra” and “text” are submitted, while “submit” is not. Again, pressing the submit button resolves this issue.
The ugly hack solution
Instead of a hidden field as in the above example, the “extra” field is a type=”text” that is hidden via CSS. Now look what happens: Pressing enter in the text field submits all three fields, exactly as it should. Functionality is identical when clicking the submit button.
July 2nd, 2009 on 5:12 am
I could not believe my eyes when I stumbled upon this issue. Thanks for putting up this issue on your website.
July 6th, 2009 on 12:40 pm
Quite frustrating, isn’t it? Hopefully posting this helped you save some time.