I need to be able to validate a form in Parsley on submit, but to delay the actual submission itself until some other (timed) action is completed.
I tried this:
$("#myform").on('submit', function(e){
e.preventDefault();
var form = $(this);
form.parsley().validate();
if (form.parsley().isValid()){
// do something here...
setTimeout(function() {
form.submit();
}, 3000);
}
});
As you can probably guess, form.submit()
just sends me into an infinite loop. I'm unable to determine how to trigger a submit after a delay without recalling the validation. To be clear, I need to:
- Check the form is valid
- Do something unrelated
- Wait X seconds
- Submit form
Any ideas? Is there a Parsley specific method that will submit the form without revalidating?