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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Don't want enter to submit a form!

Status
Not open for further replies.

FontanaS

Programmer
May 1, 2001
357
0
0
US
I have a form.
When someone hits enter inside the from when they are filling it out, it submits the form.
how do i disable that option so the only way for the user to submit the form is to click on the submit button?


thanks
 
<input type=&quot;button&quot; onclick=&quot;document.frm1.submit();&quot;> Just change your submit button to a normal button and make its onclick event submit the form.
 
does that mean that when someone hits enter in the form that it will not submit it?

thanks
 
In theory. Give it a try and tell me if enter submitted the form. I may have another idea for you to try.
 
Or you can use a graphical button outside of the form.

After the </FORM> tag add a line like:
<A HREF=&quot;JavaScript: theForm.submit()&quot;><IMG SRC=&quot;button.jgp&quot;></A>

Only a TYPE=SUBMIT button on a form will submit the form when the user hits enter on the form.
 
&quot;Only a TYPE=SUBMIT button on a form will submit the form when the user hits enter on the form&quot;

Thanks David75, that's what I thought but I wasn't sure.
 
Actually is not right, a form without a submit button, when a user hit enter, the form still will submit if the user place the cursor on one of the elements in the form. The best way is do a check at onSubmit event. ------------------
Freedom is a Right
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top