ReCaptcha v2 client side events

QFDev picture QFDev · Jul 28, 2015 · Viewed 32.7k times · Source

Does ReCaptcha v2 expose any client side events? I am looking specifically to identify when the Captcha response has been returned once the box is ticked, so I can reveal the "Continue" button below.

enter image description here

Without this it is possible for the user to click the checkbox then quickly click the submit button before the captcha response is back.

I could possible add my own click event handler to the class recaptcha-checkbox-checkmark and poll the visiblity of the tick, I just wondered if there was a simpler way to do this?

$(".recaptcha-checkbox-checkmark").click(function() {
    //...Poll for visibility of tick
});

Answer

Linus Oleander picture Linus Oleander · Dec 4, 2015

Another solution is to set data-callback directly on the g-recaptcha div, like this

<script type="text/javascript">
  var imNotARobot = function() {
    console.info("Button was clicked");
  };
</script>

<div class="g-recaptcha" data-callback="imNotARobot" data-sitekey="key"></div>