I am adding ReCAPTCHA to the site (Bootstrap Jekyll) with several contact forms. There is a popup in the footer, sometimes βcontact us nowβ and also βrequest more information about ____β on several pages.
Since I have several contact forms on the same page, I had to explicitly display each ReCAPTCHA. Here is the code for this:
In my javascript:
var CaptchaCallback = function() { grecaptcha.render('RecaptchaField1', {'sitekey' : 'my_sitekey' }); grecaptcha.render('RecaptchaField2', {'sitekey' : 'my_sitekey' }); };
In the footer (included on all pages)
<div id="RecaptchaField1"></div>
(and at the bottom of the footer)
<script src='https://www.google.com/recaptcha/api.js?onload=CaptchaCallback&render=explicit' async defer></script>
This works well on a page with two separate contact forms (i.e. I have another div on the page with the RecaptchaField2 identifier), but if I land on a page that has only one contact form, the console throws an error (unclean error: element ReCAPTCHA placeholder must be an element or identifier).
ReCAPTCHA seems to work, but can someone help me figure out what causes this error? All studies show that he imported the library twice, but I assume that this is not so, since the problem only occurs on some pages, and not on others.
Thanks!
source share