Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ReCaptcha v2 client side events

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
});
like image 499
QFDev Avatar asked Jul 28 '15 21:07

QFDev


People also ask

Does reCAPTCHA v2 still work?

In short, yes they can. While reCAPTCHA v2 and v3 can help limit simple bot traffic, both versions come with several problems: User experience suffers, as human users hate the image/audio recognition challenges.

Can I run reCAPTCHA v2 and v3 on the same page?

Can I run reCAPTCHA v2 and v3 on the same page? To do this, load the v3 site key as documented, and then explicitly render v2 using grecaptcha.render.

What are the features of reCAPTCHA v2?

reCAPTCHA v2 is a CAPTCHA service implementation from Google. It provides website protection against automated bots and spam by adding an additional widget to web forms which verifies that the user accessing the page is a real human being.

What is the difference between reCAPTCHA v2 and v3?

Like the invisible reCAPTCHA, with reCAPTCHA v3, all the user sees is the reCAPTCHA badge. However, unlike the reCAPTCHA v2, v3 does not prompt the user with a reCAPTCHA challenge when they are deemed suspicious.


2 Answers

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> 
like image 195
Linus Oleander Avatar answered Oct 06 '22 13:10

Linus Oleander


You can configure reCAPTCHA to give a callback on successful validation using the data-callback attribute on the g-recaptcha tag or via the 'callback' parameter if using explicit rendering.

See https://developers.google.com/recaptcha/docs/display#render_param

Example using explicit rendering:

var myCallback = function(val) { console.log(val); }; grecaptcha.render(    document.getElementsById('my-recaptcha-placeholder'),     {      callback: myCallback,       sitekey: mySiteKey    }); 
like image 39
Aaron Avatar answered Oct 06 '22 13:10

Aaron