toplisek 0 Newbie Poster

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>  
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.