whatgoodisaroad / validity

Client-Side Validation for jQuery
http://whatgoodisaroad.github.io/validity/
132 stars 74 forks source link

Preventing multiple submits of the form #53

Closed markvantilburg closed 10 years ago

markvantilburg commented 10 years ago

Hi,

When I have a validity on a form with the standard binding that it fires on the submit() of the form. I cannot find an option to prevent it from triggering this twice or thrice etc..

Is this build in yet, or should this be added?

This is especially important on slower internet connections or when the saving takes longer than usual. If the user presses submit again it will cancel the previous request and increases the time for the user even longer.

markvantilburg commented 10 years ago

After isValidating()


    //If the form is submitting due to a successfull validation reports true
    isSubmitting: function() {
        return this.submitting;
    },

    //true when the form is submitting
    submitting: false,

in the bind code for the form submit

                        $(this).bind(
                            "submit",
                            function() {
                                if (!$.validity.submitting) {
                                    $.validity.start();
                                    f.apply(self);
                                    $.validity.submitting = $.validity.end().valid;
                                    if ($.validity.submitting) {
                                        $(this).hide();
                                    }
                                }

                                return $.validity.submitting;
                            }

This will hide the form that the user is submitting

whatgoodisaroad commented 10 years ago

I'm not sure what this has to do with validation. Couldn't you just bind to the submit event with your own handlers? Why should this be part of validity and not separate?