Uncaught Error: ReCAPTCHA placeholder element must be an element or id
This works for me:
var CaptchaCallback = function() {
if ( $('#RecaptchaField1').length ) {
grecaptcha.render('RecaptchaField1', {'sitekey' : 'my_sitekey'
});
}
if ( $('#RecaptchaField2').length ) {
grecaptcha.render('RecaptchaField2', {'sitekey' : 'my_sitekey'
});
}
};
I got the same issue and this solution didn't work for me, but I have found one.
The fact was I used the plugin wordpress Contact form 7 and , unfortunately, I have written the keys of recaptcha in the integration part.
This made the function recaptcha/api.js was called twice and made this error.
So I have just deleted the plugin and reinstall it without fill the integration part and called the recatpcha in the files header.php and footer.php and that works :)
And don't forget to put the button recaptcha in the contact form
<div class="g-recaptcha" id="YOUR-ID" data-sitekey="YOUR-KEY" render="explicit"></div>
You can also use this in pure java script way
grecaptcha.render(document.getElementById('RecaptchaField1'), {
'sitekey' : 'my_sitekey'
});