Delaying form submission with submit()?
I'm working on a validation class that works on the following idea:
1. when user submits a form, it "pauses" the submission and the validator validates each field via an AJAX call.
2. When each field has been validated, it resumes the submission => sends the form.
But I'm having trouble resuming the submission. Here's the part of my code that doesn't work:
- //Reference to the object
- var self = this;
- //Attach the submit-event to the form
- form.submit(function(){
- //This runs when the user submits the form (I'm using the readyToSubmit variable to check if the form is ok for finishing the submission
- if (!self.readyToSubmit) {
- //Start the checking
- self.checkAllFields();
- //Disable the submit
- return false;
- } else {
- //this runs when all the validated fields are ok
- alert("GO");
- return true;
- }
When I'm testing this, everything works fine until the end, GO shows up but the form doesn't get submitted, it just stops after the "GO". How can I finish the submission?