Google reCaptcha reset doesn't work

quarky :

I want to reset Google reCaptcha widget when I submit my form via AJAX and have some input errors or form is sent. I'm using multiple widgets on the same page so I render these widgets explicitly.

My HTML code:

<div class="g-recaptcha" id="recaptcha-1"></div>
<div class="g-recaptcha" id="recaptcha-2"></div>
...
<div class="g-recaptcha" id="recaptcha-20"></div>

Loading widget

<script src="https://www.google.com/recaptcha/api.js?onload=reCaptchaCallback&render=explicit&hl=en" async defer></script>
<script>
    var reCaptchaCallback = function() {
        var elements = document.getElementsByClassName('g-recaptcha');
        for (var i = 0; i < elements.length; i++) {
            var id = elements[i].getAttribute('id');
            grecaptcha.render(id, {
                'sitekey' : 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
            });
        }
    };
</script>

After submit form:

var id = $('.g-recaptcha', form).attr('id');
grecaptcha.reset(id);

Form is the instance of the submitted form.

Everything works fine when form is fill correctly. But reCaptcha doesn't reset or reload. It try this grecaptcha.reset() but no results.

Any idea?

levi :

The grecaptcha.reset() method accepts an optional widget_id parameter, and defaults to the first widget created if unspecified. A widget_id is returned from the grecaptcha.render() method for each widget created. So you need to store this id, and use it to reset that specific widget:

var widgetId = grecaptcha.render(container);
grecaptcha.reset(widgetId);

See here.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Google's new reCaptcha doesn't work on Windows Phone

From Dev

setInterval reset loop doesn't work

From Java

Pandas reset index doesn't seem to work?

From Dev

reset interval doesn't work in javascript

From Dev

Reset and restart pygame program doesn't work

From Dev

Reset countdown interval with clearInterval doesn't work

From Dev

New recaptcha doesn't work twice in (basically) the same page

From Dev

Google reCaptcha doesn't show captcha challenge dialog on a real device

From Dev

How to reset Google recaptcha with react-google-recaptcha

From Dev

Django reset_sequences doesn't work in LiveServerTestCase

From Dev

Excel macro doesn't work after reset profile windows

From Dev

vagrant port forwarding doesn't work: Connection reset by peer

From Dev

custom uitableviewcell reset subview frame doesn't work as I wanted

From Dev

Tic Tac Toe game in React reset button doesn't work

From Dev

async / await doesn't seem to work nodejs passport reset passwd

From Dev

Passing custom html template doesn't work with reset password in django

From Dev

Submitting form doesn't work after using Recaptcha v3

From Dev

recaptcha doesn't work in Vue component.give grecaptcha.render is not a function when grecaptcha not loaded

From Dev

Google Query - "NOT LIKE" Statement Doesn't work

From Dev

Click doesn't work on this Google Translate button?

From Dev

Google Maps' stylers doesn't work?

From Python

Why doesn't .isascii() work on google colab?

From Dev

Google maps doesn't work in simplest example

From Dev

Google Analytics doesn't work in iOS

From Dev

Google map API resize doesn't work

From Dev

Google Public API Key doesn’t work

From Dev

Tooltip doesn't work in Google Scatter Chart

From Dev

Simple circle on Google maps doesn't work

From Dev

google maps doesn't work in angular directive

Related Related

  1. 1

    Google's new reCaptcha doesn't work on Windows Phone

  2. 2

    setInterval reset loop doesn't work

  3. 3

    Pandas reset index doesn't seem to work?

  4. 4

    reset interval doesn't work in javascript

  5. 5

    Reset and restart pygame program doesn't work

  6. 6

    Reset countdown interval with clearInterval doesn't work

  7. 7

    New recaptcha doesn't work twice in (basically) the same page

  8. 8

    Google reCaptcha doesn't show captcha challenge dialog on a real device

  9. 9

    How to reset Google recaptcha with react-google-recaptcha

  10. 10

    Django reset_sequences doesn't work in LiveServerTestCase

  11. 11

    Excel macro doesn't work after reset profile windows

  12. 12

    vagrant port forwarding doesn't work: Connection reset by peer

  13. 13

    custom uitableviewcell reset subview frame doesn't work as I wanted

  14. 14

    Tic Tac Toe game in React reset button doesn't work

  15. 15

    async / await doesn't seem to work nodejs passport reset passwd

  16. 16

    Passing custom html template doesn't work with reset password in django

  17. 17

    Submitting form doesn't work after using Recaptcha v3

  18. 18

    recaptcha doesn't work in Vue component.give grecaptcha.render is not a function when grecaptcha not loaded

  19. 19

    Google Query - "NOT LIKE" Statement Doesn't work

  20. 20

    Click doesn't work on this Google Translate button?

  21. 21

    Google Maps' stylers doesn't work?

  22. 22

    Why doesn't .isascii() work on google colab?

  23. 23

    Google maps doesn't work in simplest example

  24. 24

    Google Analytics doesn't work in iOS

  25. 25

    Google map API resize doesn't work

  26. 26

    Google Public API Key doesn’t work

  27. 27

    Tooltip doesn't work in Google Scatter Chart

  28. 28

    Simple circle on Google maps doesn't work

  29. 29

    google maps doesn't work in angular directive

HotTag

Archive