How to avoid internet explorer first button selection?

笑着哭i 提交于 2020-01-14 14:28:06

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!