B
B
bk_maestro2018-08-23 13:30:39
JavaScript
bk_maestro, 2018-08-23 13:30:39

How to put your event on google captcha?

The essence of the question is that I need to hang up an event on google captcha and then process this event in js. Those. I have a site on wp, there is a contact form 7, I hang an event on the captcha according to the standard (I tried absolutely everything on any block) nothing happens, it does not react to it.
I tried to do this, for example

$(document).click(function(event) {
  alert('was click to document');
})

But if I click on the captcha nothing happens, on any other element - everything is ok, it works.
I tried to do it through data-callback, also unsuccessfully, it says that: ReCAPTCHA couldn't find user-provided function: checkCallBack()
The code I used for this method is -
$('.g-recaptcha').attr('data-callback', 'checkCallBack()');
function checkCallBack() {
       alert('success function');
}

I follow the entire sequence of scripts, using the defer attribute.
Site - https://rckrt.ru/voprosy_polzovatelej/
Ps I also use
$(document).ready(function() {

} )

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2018-08-23
@bk_maestro

It 's all written in the docs

<script type="text/javascript">
      var verifyCallback = function(response) {
        alert(response);
      };
      var widgetId1;
      var widgetId2;
      var onloadCallback = function() {
        // Renders the HTML element with id 'example1' as a reCAPTCHA widget.
        // The id of the reCAPTCHA widget is assigned to 'widgetId1'.
        widgetId1 = grecaptcha.render('example1', {
          'sitekey' : 'your_site_key',
          'theme' : 'light'
        });
        widgetId2 = grecaptcha.render(document.getElementById('example2'), {
          'sitekey' : 'your_site_key'
        });
        grecaptcha.render('example3', {
          'sitekey' : 'your_site_key',
          'callback' : verifyCallback,
          'theme' : 'dark'
        });
      };
</script>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question