3

For my website I'm loading all subpages in a div that basically covers everything but the menu via jquery. The structure is like this, you press the account button, and you get the log-in form, then there's a link(that fires an onclick function) to the registration page.

I first introduced the captcha to the reg page, via the easiest method, because I couldn't get anything else to work. Everything was fine, until I added captcha to the log-in page, now the registration page doesn't render it and I get an "Uncaught Error: ReCAPTCHA placeholder element must be empty" error.

Here's how the captcha is loaded on both pages:

<script src='https://www.google.com/recaptcha/api.js'></script>
<div id="captcha" class="g-recaptcha" data-sitekey="6LeNGScO_"></div>   

The same thing on register.php but via echo

this is the function that shows the registration page

function goregister()
{
    grecaptcha.reset();
    page = 4;
    var element = "#mbody";
    var link = "/php/register.php";
    $(element).load(link);
}

I even tried adding an id to the captcha div and setting it's innerhtml to "" but it still won't help.

Cârnăciov
  • 1,169
  • 1
  • 12
  • 24
  • http://stackoverflow.com/a/27703907/1377507 – tigrang Feb 14 '15 at 08:54
  • I tried that and it removes the error from the console but none of the captchas show up. Edit:: that answer was already read by me and it's not what my problem is. That reset is so that after the forms are submitted and the info is not good, the captcha is reset without refreshing the page. My problem is that I can't load two different captchas on the same page – Cârnăciov Feb 14 '15 at 08:54

1 Answers1

2

I had this Error too:

Uncaught Error: ReCAPTCHA placeholder element must be empty

in my case the problem was, that I imported the library twince.

More exactly: My CMS MURA imported the library once, to provide reCaptcha as default service. And I imported the library the second time, not kowning.

easy going
  • 44
  • 3