Computer Hope
Software => Computer programming => Topic started by: toplisek on February 16, 2018, 04:48:59 AM
-
I have two errors with an error message:
Uncaught Error: ReCAPTCHA placeholder element must be an element or id
How to solve these errors?
Need help.
<!DOCTYPE HTML>
<html>
<head>
<title>reCaptcha</title>
</head>
<body>
<form id="MytblID" class="MytblID" action="" method="post">
<div class="g-recaptcha MYXXX-recaptcha" data-sitekey="XXX" data-expired-callback="recaptchaExpired"></div>
<script src="https://www.google.com/recaptcha/api.js?hl=en-GB&onload=Callback&render=explicit" async defer></script>
<script>
var form = "#MytblID";
var Callback = function () {
var onRecaptchaExpired = function () {
alert("Warning message as recatpcha has expired!");
// grecaptcha.reset();
};
var gRecaptchaInput = jQuery('.MYXXX-recaptcha');
gRecaptchaInput.each(function (key)
{
var $this = jQuery(this);
var siteKey = $this.data('sitekey');
$this.html('');
grecaptcha.render(document.getElementById($this.attr('id')),
{
'sitekey': 'XXX',
'expired-callback': onRecaptchaExpired
}
);
}
);
};
</script>
</form>
</body>
</html>
-
I solved it by adding render="explicit" and onloadCallback={console.log.bind(this, "recaptcha loaded")}