prevent form submit ...

  • Thread starter Thread starter Lloyd Dupont
  • Start date Start date
L

Lloyd Dupont

I have a web form with multiple part.
I do want the user to click the submit button to post back, so I know which
functionality was triggered.

unfortunately, when the focus is any text box, if the user hit ENTER the
form is submitted, how could prevent that ?

thanks, ...
Lloyd
 
hehe, regarding your samples I found I could simply write:
onkeydown="if ((event.which && event.which == 13) ||
(event.keyCode && event.keyCode == 13))
return false;"

and that remove the form triggering !
hhmm.. maybe I could a default button too... anyway thanks :-)
 
If the user hits enter it triggers exactly the same action as clicking the
default submit button. What exactly are you trying to accomplish? If you
don't want to allow the user to submit the form don't create any submit
buttons... And if for some reason you have a script in your onclick event on
the submit button then just move it to onsubmit event of the form...

Jerry
 
Right, that was one of the examples in the links I gave you.
I'm glad it worked out well for you.
 
I have multiple section on my web page.
like 'unregister section' and 'update profile section'

so I could not 'just submit' the form.
I need the user to click on one button, so I know if it unregister, or if it
just update on its profile.

otherwise, mmhh.. what would you do ?

and no, I rather have them both on the same page than on 2 empty otherwise
page.
 
Back
Top