One way to stop form submission is to return false from your JavaScript function.
When the submit button is clicked, a validation function is called. I have a case in form validation. If that condition is met I call a function named returnToPreviousPage();
function returnToPreviousPage() {
window.history.back();
}
I am using JavaScript and Dojo Toolkit.
Rather going back to the previous page, it submits the form. How can I abort this submission and return to the previous page?
There are many ways to achieve it.
one can be using preventDefault() and validateForm()
Here validateMyForm() will returns false if validation gets failed.
You can also use the return value of the function to prevent the form submission
and function like
In case of Chrome 27.0.1453.116 m if above code does not work, please set the event handler’s parameter’s returnValue field to false to get it to work.
Thanks Sam for sharing information.