[thelist] Stopping Form Submission when Enter is hit

Darren Darren at web-bitch.co.uk
Wed Jul 18 08:32:51 CDT 2001


afternoon,

is there any reliable way to stop for submission when the user hits
enter??

we have a form with lots of text boxes and anything up to 6 submit
buttons posting back to an ASP page.  the problem is that when the
user is banging in all the data, they hit return in the text box,
which fires the form submission.

this is all in ie5.5 (corporate intranet site - ain't i the lucky one!
:>)

i've tried catching the keycode of the key hit - which i can do, but
the event bubbles up to the onclick event handler and fires the form
submission anyway!

also tried to set a variable that is set to true in the onclick of the
submit buttons, but again enter acts like you've just clicked the
button.

one more thing is that if you display the keycode in the onclick of
the submit button, you get 0 for both a mouse click and for the user
hitting return (the ms site says that the enter key fires the onclick
event!), so i can't seem to trap it there....

so any one got any ideas on how to stop this so i can have a well
behaved form and the users don't run the risk of accidentally deleting
their data??

thanks all,

darren.





More information about the thelist mailing list