{"id":1869,"date":"2009-11-17T04:04:46","date_gmt":"2009-11-16T23:04:46","guid":{"rendered":"http:\/\/www.chiragmehta.info\/chirag\/?p=1869"},"modified":"2009-11-17T04:06:03","modified_gmt":"2009-11-16T23:06:03","slug":"submit-a-form-in-internet-explorer-with-enter","status":"publish","type":"post","link":"https:\/\/www.chiragmehta.info\/chirag\/2009\/11\/17\/submit-a-form-in-internet-explorer-with-enter\/","title":{"rendered":"Submit a Form in Internet Explorer with Enter"},"content":{"rendered":"<p>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.<\/p>\n<p><code>&lt;form action=&quot;&quot; method=&quot;post&quot;&gt;<br \/>    &lt;fieldset&gt;<br \/>        &lt;label for=&quot;user_name&quot;&gt;User Name&lt;\/label&gt;<br \/>        &lt;input type=&quot;text&quot; name=&quot;user_name&quot; id=&quot;user_name&quot; \/&gt;<br \/>    &lt;\/fieldset&gt;<br \/>    &lt;fieldset class=&quot;button&quot;&gt;<br \/>        &lt;button type=&quot;submit&quot; name=&quot;submit&quot; id=&quot;submit&quot; title=&quot;Verify User Name&quot;&gt;Verify User Name&lt;\/button&gt;<br \/>    &lt;\/fieldset&gt;<br \/>&lt;\/form&gt;<\/code><\/p>\n<p>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.<\/p>\n<p><code>&lt;form action=&quot;&quot; method=&quot;post&quot;&gt;<br \/>    &lt;fieldset&gt;<br \/>        &lt;!--[if IE]&gt;&lt;input type=&quot;text&quot; style=&quot;display: none;&quot; disabled=&quot;disabled&quot; size=&quot;1&quot; \/&gt;&lt;![endif]--&gt;<br \/>        &lt;label for=&quot;user_name&quot;&gt;User Name&lt;\/label&gt;<br \/>        &lt;input type=&quot;text&quot; name=&quot;user_name&quot; id=&quot;user_name&quot; \/&gt;<br \/>    &lt;\/fieldset&gt;<br \/>    &lt;fieldset class=&quot;button&quot;&gt;<br \/>        &lt;button type=&quot;submit&quot; name=&quot;submit&quot; id=&quot;submit&quot; title=&quot;Verify User Name&quot;&gt;Verify User Name&lt;\/button&gt;<br \/>    &lt;\/fieldset&gt;<br \/>&lt;\/form&gt;<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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. &lt;form action=&quot;&quot; method=&quot;post&quot;&gt; &lt;fieldset&gt; &lt;label for=&quot;user_name&quot;&gt;User Name&lt;\/label&gt; &lt;input type=&quot;text&quot; name=&quot;user_name&quot; id=&quot;user_name&quot; \/&gt; &lt;\/fieldset&gt; &lt;fieldset class=&quot;button&quot;&gt; &lt;button type=&quot;submit&quot; name=&quot;submit&quot; id=&quot;submit&quot; title=&quot;Verify User Name&quot;&gt;Verify User [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[27,7],"class_list":["post-1869","post","type-post","status-publish","format-standard","hentry","tag-javascript","tag-others","post-preview"],"_links":{"self":[{"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/posts\/1869","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/comments?post=1869"}],"version-history":[{"count":2,"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/posts\/1869\/revisions"}],"predecessor-version":[{"id":1871,"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/posts\/1869\/revisions\/1871"}],"wp:attachment":[{"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/media?parent=1869"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/categories?post=1869"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/tags?post=1869"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}