| This is a response to Naruki's
question yesterday.
What makes the web page submit when you press Enter? and how does the form know which button you expected to be pressed?
Submitting the form when the user presses enter is not behavior that is defined by the HTML standards, but it's not specifically prohibited either. It's just a design choice the browser makers made. The issue of which submit button is "pressed" when the user hits enter is undefined. MSIE clicks the first submit button.
These are all design issues you should take into account when designing your form. For example, when UF comment system was redesigned recently, they put the submit button first, then the preview button. Unfortunately when users hit enter their comments were submitted whether they were ready or not, resulting in a lot of inanane comments (um, well, more than usual anyway :-) ). The UFies that be rearranged the form so that the "Submit" button goes second, and that furthermore the comment isn't submitted unless that button is sent.
JavaScript can be used to catch the button click and form submit events and give the user a chance to cancel those events.
Here are some links to further details about submit buttons and JavaScript:
|