I have a multi-step form which steps through using POST requests to pass state to each controller action.
New > Preview > Checkout > Create
Preview and Checkout are POST requests do not impact the database so form resubmission is perfectly OK.
I am looking to:
1. Prevent the default submit in order to run some javascript validation
2. After validation submit the form and allow browser back and forth
While listening to the submit event I have tried to e.preventDefault() and then e.submit(), however, this does not allow for form resubmission when using the browser buttons.
However, if an error is thrown, the form submits and allows use of the browser back and forth buttons.
How can I get this functionality without throwing an error?
$('#new_post').on("submit", function(e) {
throw new Error();
// this allows for form submission and back and forth button functionality
}