jQuery Function Does Not Fire if Gravity Form Entry Fails

I am using jQuery to add a "disabled" attribute to my submit button once it is clicked.

        $('#submit-button').click(function () {
            setTimeout(function () {
                $('#submit-button').attr('disabled', 'disabled')
            }, 50);
        })

I am using gravity forms and am using AJAX to produce a spinner image when it’s clicked, that’s why I have the setTimeout function.

This works the first time the submit button is clicked. If the entry passes validation then it’s no problem, the disabled attribute is loaded and then goes to the confirmation page.

The issue is when the validation fails, the page refreshes and shows the errors (e.g. this was not filled out correctly) and then click the submit button does not fire the jQuery click function to add the disabled attribute

25 thoughts on “jQuery Function Does Not Fire if Gravity Form Entry Fails”

Leave a Comment