submit the form by clicking the button only.

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
When the user type something in text box, and press enter, it will
submit the form data
to test2.jsp, even without pressing submit form button. This is not
what I want, I want to
submit the form only when the user press the submit button. Any
workarounds? Please advise.

<script type="text/javascript">
function submit_me()
{    alert("submit me");

<FORM NAME="InputForm" ACTION="test2.jsp" METHOD="POST">
name <input type="text" name="userName">
<input type="button" onClick="submit_me()" value="submit form">

<%= request.getParameter("userName") %>

Re: submit the form by clicking the button only.

Quoted text here. Click to load it

You do not need JavaScript to submit the form. You might need JavaScript
to do what you are attempting to do (suppress the ability for the submit
to be invoked by the 'Enter' key), but you do not need it to submit the

<form name="InputForm" action="test2.jsp" method="POST">
name <input type="text" name="userName">
<input type="submit" value="submit form">

As for messing with browser functionality and preventing the 'Enter' key
from submitting the form, you can find multiple variations of that theme


comp.lang.javascript FAQ -

Site Timeline