HTML tip for broken "Submit on Enter" functionality 3
Here’s a little 2-hour bug fix for you. The time it took me to figure this one out (about 2 hours) was inversely proportional to the significance of the bug (an edge case in a couple browsers for form tags with password fields):
If you have the following recipe:
- form tag with
- a text field and
- a password field and
- you want a user to be able to submit the form upon hitting enter
... you must have a < input type="submit" /> tag in your form. This is important to know if you’re doing anything funny by submitting your form with an anchor link, javascript or witchcraft. If you don’t want people seeing that submit tag, just make it “display: none;” in your CSS. Bam.
Here’s my proof.
Tested in Firefox 2.0.0.1, IE6, and IE7.