Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

submitting a form by pressing 'Enter'

Status
Not open for further replies.

GezH

Programmer
Aug 7, 2002
68
I have a form within my JSP page. If the user submits the form by pressing enter and not by pressing the submit button, it has unwanted outcomes.

Is there anything I can do to test how the form has been submitted, and to mimick the pressing of the button is Enter is pressed?

Thanks for any advice.
 
How about using javascript to submit. Call the button a button rather than a submit. Call a JScript onClick to submit the form.

<input type=&quot;button&quot; name=&quot;myButton&quot; onClick=&quot;takeMe()&quot;>
<script>
function takeMe() {
document.forms[0].submit();
}
</script>

DeZiner
Never be afraid to try something new.
Remember that amateurs built the Ark.
Professionals built the Titanic
 
No, my problem is that if Enter is pressed, the action of pressing the button is not achieved. Therefore when I go to check various request parameters on the next page, they don't exist. Tricky.
 
Using a button instead of a submit will cause the user to press the button. The return or enter key won't submit the form.

DeZiner
Never be afraid to try something new.
Remember that amateurs built the Ark.
Professionals built the Titanic
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top