Mario Alexander Mario Alexander - 11 months ago 38
Java Question

Javascript how to stop form from submitting

anyone has any ideas how to stop jsp pages from submitting? I'm using java spring 2.0. And I'm using form controller, so when i click the submit button then it goes to the validation method.

here the submit button:

<input type="submit" name="_target" value="Next" onClick="next()"

My plan is, i put the confirmation in my javascript, if confirm is 'OK' then it will do nothing. But at my current situation, it always goes to validae controller immediately.

Thanks for your helps.

Answer Source

This basically should return true or false from the confirm box and then take it to the validation function. Could you please try it by yourself because I'm not pretty confident about this.

<input type="submit" name="_target" value="Next" onClick="next();return confirm("Are you sure?");">