Maybe something like this:
$("#myForm").bind("submit", function() {
$(this).validate(validation_options);
var valid = $(this).valid();
if (valid) {
// lock form, show loading animation, do submit
}
// you don't really need an 'else' here.
// the errors should display if it's not valid.
});
On Oct 13, 5:35 am, Opally <[email protected]> wrote:
> This is a question about the jquery Validation plugin.
>
> I need to lock the submit button on some forms to prevent multiple
> submissions, but I don't want to permanently lock it, in case there's
> a validation problem that the user needs to resolve. I did come up
> with a way to temporarily lock it and change the text to "Saving,
> Please Wait..." for a few seconds, then revert it to an unlocked
> submit button.
>
> The problem I'm having is that this conflicts somehow with the jquery
> validation plugin. Some fields that have error messages if the user
> attempts to submit the form with missing data. If I use the temporary
> locking submit button (which uses an animation to create a duration)
> then these error messages do not display.
>
> Is it possible to test for a validation value in a separate function
> before running this lock function? If valid, lock, if not valid, don't
> lock, because it isn't possible to submit an invalid form anyway.
>
> I tried wrapping the locking submit function in a setTimeout, but that
> didn't have any effect at all in delaying it.