473,474 Members | 1,836 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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") %>

Jul 23 '05 #1
1 10490
<jr********@hotmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr 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 <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Mark Michel | last post by:
Hi. I have made an html form which I would like to send by e-mail. When the recipient receives the e-mail form, I would like them to be able to fill it out and click the Submit button which will...
2
by: Matt | last post by:
I tried to figure out how many approaches to submit form data. Here's my attempts. Please advise. Thanks!! 1) html submit button, most commonly used. <form name="formName" action="url"...
2
by: Terence Parker | last post by:
How does one go about submitting a form with a link - but submitting it to a new window AND to a page different to that described within the action="" option of the <form> tag? Say, for example,...
1
by: Frank | last post by:
Does anyone know why this doesn't seem to work on certain browsers / versions? <form name="formulier" action="script.cgi" method="post"> <a href="#" onClick="document.formulier.submit()"><img...
6
by: CJM | last post by:
Can somebody clarify if/how/when a simple form is submitted when the <Enter> key is pressed? As I understood it, if you have a form with a single submit button, if enter is pressed, the form...
6
by: tencip | last post by:
Hi everyone, So, i've got a form that is very simple. It hold three elements: username, password, and domain. The goal here is to have the form submit the login to an administrative section...
1
by: Andy Kasotia | last post by:
I have an ASP UI with VB Dll as a COM object that access the DB2 Database. I have a "Calculate" button on the ASP Page which when clicked does form validation (javascript) and submits the form...
1
by: sam | last post by:
Hi All, I have a form with 4 checkboxes and 4 text boxes and one submit button. The form should work such a way when I select a particular checkbox and give a url in text box, the form should...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.