0

How to modify this script to work with all options using Google Callback function?

<!DOCTYPE HTML>

<html>

<head>
  <title>gCaptcha</title>
</head>

<body>
<form id="mycontactform1" method="post">

<script type="text/javascript">
var RecaptchaOptions = {"curl_timeout":1,"lang":"en"};
    function captchaSubmit(data) {
        document.getElementById("mycontactform1").submit();
    }

function IsRecapchaValid()
{
  var res = grecaptcha.getResponse(form);
  if (res == "" || res == undefined || res.length == 0)
  {
    return false;
  }
  return true;
}
</script>

<script>
var form = "mycontactform1";
var Callback = function () {

  var reCaptchaFields = jQuery('.myid-recaptcha');

  reCaptchaFields.each(function (key)
    {
      var $this = jQuery(this);
      var siteKey = $this.data('sitekey');
      $this.html('');
      grecaptcha.render(document.getElementById($this.attr('id')),
        {
        'sitekey': siteKey
        }
      );
    }
  );
};

</script>
<script src="https://www.google.com/recaptcha/api.js?hl=en&onload=Callback&render=explicit" async defer></script>
<div class="g-recaptcha myid-recaptcha" data-sitekey="" ></div>

<input type="submit" name="formsubmit1" data-callback="captchaSubmit" value="Send" class="" />

</form>
</body>

</html>  
1
Contributor
0
Replies
7
Views
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.