Pressing "Return" in a HTML-Form with multiple Submit-Buttons

DiegoFrings picture DiegoFrings · Jan 20, 2010 · Viewed 14.4k times · Source

Let's imagine a HTML-form with with two submit buttons. one of them is positioned in the upper half of the form and does something less important. the other button is the actual submit button, which saves the entered data. this button is positioned at the end of the form. the two buttons will trigger different action-urls.

experienced users like to submit their forms by pressing "enter" or "return" instead of clicking on the according button.

unfortunately, the browser will look for the first submit-button of the current form and use this to execute the form-submit. since in my form the second button is the actual submit-button, i need to tell the browser to use this particular button (or the action-url that is associated with it).

i don't link javascript listeners, which are looking for key pressed or something like that. so i'm looking for a better approach to this problem. however, javascript or jquery solutions (without keypressed-listerner) are welcome.

thank you very much for your help in advance.

Answer

Lucas picture Lucas · Jan 20, 2010

change your first button to a <input type="button" />.