22

What is the best way to detect if a reCaptcha v2 does not load? I would like to alert users when they need to use the captcha to continue, but it was unable to load.

Matt
  • 1,707
  • 1
  • 16
  • 18
  • 3
    You can specify an onload callback function, see https://developers.google.com/recaptcha/docs/display#explicit_render – that would be “the other way around”, but probably more reliable than trying to check the opposite. – CBroe Aug 19 '16 at 12:36

1 Answers1

15

You can pass a callback function when you make the request for the captcha

Add this to the url:

?onload=myfunction

for example:

 <script src="https://www.google.com/recaptcha/api.js?onload=loadedCallback&render=explicit"
        async defer>
    </script>

Js:

function loadedCallback(){
//Recaptcha its loaded
}