Form submit by enter key and Internet Explorer


Ran into an (other) interesting Internet Explorer bug. Seems that if you have a form with only a single text input, hitting the enter button will not submit the form in IE.

The solution is to hide an additional disabled input for IE to find, using IE conditional Comments and hiding it from view with some CSS.
01.<form action="" method="post">
02. <fieldset>
03. <!--[if IE]>
04.<input type="text" style="display: none;" disabled="disabled" size="1" /><![endif]-->
05. <label for="user_name">User Name</label>
06.<input name="user_name" id="user_name" type="text">
07. </fieldset>
08. <fieldset class="button">
09. <button type="submit" name="submit" id="submit" title="Verify User Name">Verify User Name</button>
10. </fieldset>

11.</form>

Now the form will submit in IE when you hit the enter key!

Advertisements
By karuppasamy11486 Posted in 1

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s