• Scenario: You fill out the form, get the tick with recaptcha, but miss a required field and get the prompt. You complete the required field and try to resubmit. Form now fails with “Captcha mismatch, Please try again.” – except there’s no option to recheck the box since it’s still checked. Shouldn’t the recaptcha reset after a failed submission?

    Ninja Forms Version 2.9.45
    Ninja Forms reCAPTCHA Version 1.2.5

    https://www.ads-software.com/plugins/ninja-forms-recaptcha-field/

Viewing 3 replies - 1 through 3 (of 3 total)
  • I have exactly the same problem. Anyone a solution?

    thanks!

    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.

    (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.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Captcha mismatch after failed submission’ is closed to new replies.