Enter does not submit form in IE due to hidden button

I have a form with two buttons. The first is hidden using Javascript.

When I press enter in a text box in IE, the form is not submitted. I guess this is because he selected the first button as the default submit button, but since this button is hidden, it does not work.

I solved this by sending the form to a Javascript event to enter the key. However, it also submits the form if the user presses the enter button to select an item from the browser autofill drop-down list.

example autocomplete dropdown

How to submit a form in IE without breaking autocomplete functionality?

+7
javascript internet-explorer autocomplete submit
source share
4 answers

We had a similar problem a few years ago, and AFAIR we added an extra button to the top of the form, which always performs the default submit action when clicked in IE. This button can be โ€œalmost hiddenโ€ by giving it a 1x1 transparent image.

+5
source share

Try to hide the button with the following class:

.hidden-element { width: 0px; height: 0px; position: absolute; top: -99999px; left: -99999px; } 
+10
source share

I fixed it with opacity 0, for example:

 <input type="submit" style="width: 0px; height: 0px; opacity: 0;" id="submitBtn" name="submitBtn"> 
+5
source share

You can add an additional button to preserve the functionality of the submit button as follows:

 <![CDATA[<!--[if IE]>]]> <input type="text" style="display: none;" disabled="disabled" size="1" /> <![CDATA[<![endif]-->]]> 
0
source share

All Articles