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?
views:
159answers:
3
+4
A:
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.
cletus
2009-07-06 14:58:17
I think the solution should be extended with the fact that the button should have onclick ="return false;" and also it should be hidden with width:0px.
M3rlino
2009-07-06 15:22:52
What benefit is width:0px over display:none?
cletus
2009-07-06 22:51:41
+2
A:
You need to disable the Enter key for those input elements to prevent form submission. Take a look at this article.
Peter
2009-07-06 14:59:54
It could be a good solution. In my case i preferred to use cletus'solution.
M3rlino
2009-07-06 15:11:37
+2
A:
Lots of discussion about this here: http://stackoverflow.com/questions/585396/how-to-prevent-enter-keypress-to-submit-a-web-form/
DanSingerman
2009-07-06 15:00:01