idan traders
idan traders

Reputation: 79

ReCAPTCHA placeholder element must be an element or id

i have some problem with google recaptcha.

i put 2 recaptachs in same website but in deferent locations.

  1. i place in the footer like:

<div class="g-recaptcha" id="recaptcha1"></div>

  1. i place in contact us like:

<div class="g-recaptcha" id="recaptcha2"></div>

but its give me this error: ReCAPTCHA placeholder element must be an element or id.

my code:

    <script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit" async defer></script>

<script type="text/javascript">

    var recaptcha1;
    var recaptcha2;

    var onloadCallback = function() {
        //Render the recaptcha1 on the element with ID "recaptcha1"
        recaptcha1 = grecaptcha.render('recaptcha1', {
            'sitekey' : '*******', //Replace this with your Site key
            'theme' : 'light'
        });

        //Render the recaptcha2 on the element with ID "recaptcha2"
        recaptcha2 = grecaptcha.render('recaptcha2', {
            'sitekey' : '*******', //Replace this with your Site key
            'theme' : 'light'
        });

        grecaptcha.reset(recaptcha1);
        grecaptcha.reset(recaptcha2);
    };
</script>

i plase all the script and the code in the before

i did a reserach here but its still not working.

thanks for all the help.

Upvotes: 1

Views: 9311

Answers (1)

mohit saroha
mohit saroha

Reputation: 48

attach your script only once and after captcha tag

Upvotes: 1

Related Questions