|
Answer» 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. Code: [Select]<!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")}
|