Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • (function($) {
        $(document).ready(function() {
            jQuery(".ninja-forms-form").on('submitResponse.resetCaptcha', function(e, formData, jqForm, options){
                if (typeof grecaptcha !== 'undefined') {
                    // add error manually if captcha isn't solved
                    if (!grecaptcha.getResponse()) {
                        jQuery("#ninja_forms_field_8_error").prop("innerHTML", 'Please confirm that you are human');
                    }
    
                    // reset captcha
                    if (grecaptcha.getResponse()) {
                        grecaptcha.reset();
                    }
                }
            });
        });
    })(jQuery);

    A slightly improved version.

    This is my solution to the problem:

    (function($) {
        $(document).ready(function() {
            jQuery(".ninja-forms-form").on('submitResponse.resetCaptcha', function(e, formData, jqForm, options){
                if (grecaptcha && grecaptcha.getResponse()) {
                    grecaptcha.reset();
                }
            });
        });
    })(jQuery);

    It resets the captcha state (if it was activated) after submitResponse event. This is a solution for ajax powered form.

Viewing 2 replies - 1 through 2 (of 2 total)