By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,276 Members | 2,063 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,276 IT Pros & Developers. It's quick & easy.

disable enter within form

P: n/a
Hi Folk

I have a form with the following structure:

<form onsubmit="getsearchdata();">
lots of input boxes here
<input type="submit" name="submit" onsubmit="getsearchdata();">
</form>

In Opera, whenever someone presses the <enterbutton, the form is
submitted and the onsubmit does not event get any attention. When the
submit button is clicked, it obviously works....

How can I change this?

TIA
Nicolaas
Feb 25 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Feb 26, 11:13 am, "windandwaves" <nfranc...@gmail.comwrote:
Hi Folk

I have a form with the following structure:

<form onsubmit="getsearchdata();">
lots of input boxes here
<input type="submit" name="submit" onsubmit="getsearchdata();">
</form>

In Opera, whenever someone presses the <enterbutton, the form is
submitted and the onsubmit does not event get any attention. When the
submit button is clicked, it obviously works....

How can I change this?

TIA
Nicolaas- Hide quoted text -

- Show quoted text -
I think I solved it by changing it as follows:

<form onsubmit="return !getsearchdata();">
lots of input boxes here
<input type="submit" name="submit" onsubmit="return !
getsearchdata();">
</form>

Ta

Nicolaas

Feb 25 '07 #2

P: n/a
windandwaves said the following on 2/25/2007 5:27 PM:

<snip>
I think I solved it by changing it as follows:

<form onsubmit="return !getsearchdata();">
Either way, you must return a value for it to make any difference of
whether the form gets submitted or not. Whether it is !getsearchdata()
or getsearchdata() depending on what the function returns.
lots of input boxes here
<input type="submit" name="submit" onsubmit="return !
getsearchdata();">
There is no onsubmit handler for a submit button. The onsubmit here is
wasteful and unneeded.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Feb 26 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.