Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > submit the form by clicking the button only.

Reply
Thread Tools

submit the form by clicking the button only.

 
 
jrefactors@hotmail.com
Guest
Posts: n/a
 
      12-23-2004
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") %>

 
Reply With Quote
 
 
 
 
Grant Wagner
Guest
Posts: n/a
 
      12-23-2004
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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 <(E-Mail Removed)>
comp.lang.javascript FAQ - http://jibbering.com/faq


 
Reply With Quote
 
 
 
Reply

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert form to submit on load instead of clicking submit button? Network-Man HTML 5 07-07-2012 12:06 PM
javascript submit() function performs differently from clicking submit ljlolel Javascript 2 05-18-2006 04:35 PM
submit the form data to the popup window without a submit button jrefactors@hotmail.com HTML 2 01-01-2005 06:07 AM
submit the form by clicking the button only. jrefactors@hotmail.com Javascript 1 12-23-2004 06:50 PM
Form submit - hitting enter does not trigger Submit button ASP General 2 10-25-2004 03:37 PM



Advertisments