Click to See Complete Forum and Search --> : cancelling a submit
richy
Feb 26th, 2001, 10:24 AM
I'm trying to stop my form from submitting when I press enter on a text box, but I can't find out how to do it.
I've tried doing document.selectform.submit=false;, but this doesn't work.
winapi
Feb 26th, 2001, 11:39 PM
Hi,
Leave the submit button out of the form. Make a regular button with onclick event to submit the form.
<form name="test" method="post" index="test.html">
<input type="text" name="blah" >
<input type="button" value="Submit" onclick="document.test.submit();">
</form>
by changing the submit button to a regular button, enter will no longer submit the form.
Let me know if this helps.
richy
Feb 27th, 2001, 03:09 AM
I'm afraid that can't be the problem, because I don't actually have a submit button on my form. The only button I have is set up as the following:
<input type=button value='Find' onClick='promptSearch()' name=btnfind>
Just incase it interests anybody, I have the following in my form header:
<form name=selectform action=results2.asp>
Any more ideas?
richy
Feb 27th, 2001, 06:08 AM
By looking at the following tip:
http://webreference.com/js/tips/000501.html
This seems to be the fix of my problem. My only niggle is that I don't know how to set it up, as I have an action setting for my form rather than an onSubmit. Does anybody know, but looking at my first post as well, how I can set this whole thing up?
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.