Wednesday, March 23, 2011

In ASP.NET, ENTER key on a FORM with a single Input Field, will automatically SUBMIT.

This happens in IE, Chrome, but not in Firefox.
Solution: add another hidden input field. Such as:

<div style="display: none">
    <input type="text" name="hiddenText" />
</div>


Reason:
Because IE and Chrome following HTML2.0 Specification exactly.
According to HTML2.0 Specification, 8.2. Form Submission:

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.


No comments:

Post a Comment