I have a form that has a submit button in it somewhere.
However, I would like to somehow 'catch' the submit event and prevent it from occurring.
Is there some way I can do this?
I can't modify the submit button, because it's part of a custom control.
Best Solution
Unlike the other answers, return
false
is only part of the answer. Consider the scenario in which a JS error occurs prior to the return statement...html
script
returning
false
here won't be executed and the form will be submitted either way. You should also callpreventDefault
to prevent the default form action for Ajax form submissions.In this case, even with the bug the form won't submit!
Alternatively, a
try...catch
block could be used.