1

I have used multi step sign up form using jQuery.stepy.js Also I have added google ReCAPTCHA using 'gem "recaptcha"'. When I am placing

  <%= recaptcha_tags %>

inside wizard form it is throwing JavaScript error like this:

Uncaught Error: ReCAPTCHA placeholder element must be empty

I have searched for the reason behind this error and found that this error occurs if the google recaptcha library is loading twice. Is this happening because of jQuery.stepy.js ? How can I resolve this error?

Ankur M
  • 23
  • 4
  • Does this error occur if you remove the `<%= recaptcha_tags %>`? Can you show the full error script from the browser's javascript console? – max pleaner Jun 09 '17 at 07:51
  • No, the error doesn't occur if I remove the <%= recaptcha_tags %>. Full error is: Uncaught Error: ReCAPTCHA placeholder element must be empty at Wp (recaptcha__en.js:394) at recaptcha__en.js:399 at Jp (recaptcha__en.js:389) at recaptcha__en.js:398 at recaptcha__en.js:410 Wp @ recaptcha__en.js:394 (anonymous) @ recaptcha__en.js:399 Jp @ recaptcha__en.js:389 (anonymous) @ recaptcha__en.js:398 (anonymous) @ recaptcha__en.js:410 – Ankur M Jun 09 '17 at 10:34

1 Answers1

0

This error occurs when recaptcha/api.js file gets loaded multiple times.

In your case you have used <%= recaptcha_tag %>, this tag inject api.js by default everytime it renders. Just check you haven't added the library file explicitly or using multiple recaptcha tags (each one will inject library script).

You can set :script param to false, by passing argument to method:

<%= recaptcha_tag :script => false %>
Rahul Sagore
  • 1,588
  • 2
  • 26
  • 47