Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery click event on Google reCAPTCHA

I would like to capture a click event on Google reCAPTCHA like below.

Google reCAPTCHA robot checkbox image

I am using the below code.

jQuery('#I0_1444640729099').on('load', function() {
    jQuery(".recaptcha-checkbox-checkmark").click(function() {
        alert("test");
    });
});

But I cannot do that. Can anyone help me in this regard?? I would like to catch the successful captcha submission event too.

like image 646
abu abu Avatar asked Oct 12 '15 09:10

abu abu


1 Answers

You can add a data-callback to the DIV that Google gives you:

<div class="g-recaptcha" data-callback="recaptchaCallback" data-sitekey="RECAPTCHA_KEY"></div>

Then you add the callbak function to your code:

$("#g-recaptcha-response").on("click", function(){
    alert("test"); });

I hope I've helped

like image 151
Alex Peñaloza Avatar answered Nov 15 '22 14:11

Alex Peñaloza