问题
I have one form with several text fields and one button. When i enter one of the text fields, the submit button become highlighted and if i press enter while typing, the button is pressed, so i got an unexpecte behaviour because my page is submitted. Firefox doesn't act such a way.
Is there some attribute or configuration to avoid this undesired behaviour or i have to use some javascript technique?
回答1:
Generally what I do in this situation is make the first button on the form do nothing and then hide it with CSS. Kludgy? Sure. Effective? Absolutely.
In fact, this is a duplicate of Stopping IE from highlighting the first submit-button in a form.
回答2:
You need to disable the Enter key for those input elements to prevent form submission. Take a look at this article.
回答3:
Lots of discussion about this here: How to prevent ENTER keypress to submit a web form?
来源:https://stackoverflow.com/questions/1087438/how-to-avoid-internet-explorer-first-button-selection