Go Back   Velocity Reviews > Newsgroups > HTML
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

HTML - submit the form by clicking the button only.

 
Thread Tools Search this Thread
Old 12-23-2004, 05:52 PM   #1
Default submit the form by clicking the button only.


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.
thanks!!


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

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



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



jrefactors@hotmail.com
  Reply With Quote
Old 12-23-2004, 06:50 PM   #2
Grant Wagner
 
Posts: n/a
Default Re: submit the form by clicking the button only.

<> wrote in message
news: oups.com...
> 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.
> thanks!!
>
>
> <script type="text/javascript">
> function submit_me()
> { alert("submit me");
> InputForm.submit();
> }
> </script>
>
> <FORM NAME="InputForm" ACTION="test2.jsp" METHOD="POST">
> name <input type="text" name="userName">
> <input type="button" onClick="submit_me()" value="submit form">
> </FORM>


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.

<!-- NO JAVASCRIPT NEEDED -->
<form name="InputForm" action="test2.jsp" method="POST">
name <input type="text" name="userName">
<input type="submit" value="submit form">
</form>

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

<url:
http://www.google.ca/search?q=javasc...ey+submit+form
/>

--
Grant Wagner <>
comp.lang.javascript FAQ - http://jibbering.com/faq


  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump