views:

160

answers:

1

This is a follow on to my previous question:

JSP / servlet / IE combination doesn’t submit form detail on Enter

Inside the form, we have:

<input ... type="submit" name="confirm" value="Confirm"/>

There are no input fields on this form. This form appears at the end of a workflow and is essentially a verification to proceed.

This form is not submitted to either IE or Firefox when the Enter key is pressed. It works perfectly if the "Confirm" button is pressed.

Following on the answer to my previous question, I have tried adding dummy fields such as:

<input type="hidden" />

or

<input type="text" style="display: none;" />

but they make no difference.

For various reasons, we would prefer not to use Javascript.

Any suggestions to get the Enter key to submit?

+2  A: 

Unfortunately, you should have at least one focusable input element in the form to get that to work and then only when the input has focus. If you don't have any input elements, then there's no other way to get around this than by letting Javascript to listen on the enter key in the body.

<body onkeypress="if (event.keyCode == 13) document.formname.confirm.click();">

Where formname is the value of the name attribute of the parent <form> element.

Note that I used document.formname.confirm.click() instead of document.formname.submit(), because otherwise IE wouldn't send the name=value pair of the button to the server side.

The only Javascript-free way would be to let the user to tab to the button and then press enter. This all is by the way regardless of the browser used and thus not IE specific.

BalusC