Page 1 of 1

reCaptcha v2 not working for me

Posted: Mon Oct 04, 2021 1:52 pm
by rvwilliams
I'm trying to include reCatcha v2 to my CGBetterForms form. The code appears but I am able to click Submit without ticking the reCaptcha box for 'Im not a robot'.
CMSMS is version 2.2.14
Captcha version 1.0
CGBetterForms 1.10.4

I have configured Captcha to use ReCaptcha and added the Site Key and Secret values.

My form includes
<div class="g-recaptcha" data-sitekey="... site key ..."></div>

<div class="form-group">
<button type="reset">Reset</button>
<button type="submit">Submit</button>
</div>

The form validations include Validate Captcha

The page with the form has Page Specific Data
<__script__ src="https://www.google.com/recaptcha/api.js" async defer></__script>

What have I missed out?

Re: reCaptcha v2 not working for me

Posted: Wed Oct 06, 2021 1:31 am
by DIGI3
In CGBF, under validators, click "auto add validations" or something similar. It doesn't work if you manually add just the captcha one, it's a bug in the module and the author abandoned it before it was fixed. There is a fork of it out now, I'm not sure if that bug has been fixed in it or not yet: http://dev.cmsmadesimple.org/projects/smartforms

Re: reCaptcha v2 not working for me

Posted: Mon Oct 11, 2021 12:30 pm
by rvwilliams
I have the Captcha validation set but I can still submit a form without checking the reCaptcha tick box.

When I look at the form under CGBetterForms, there is a message saying:

NOTICE: No captcha container was detected in the form markup.

Is this why it doesn't check to see if the reCaptcha validates?

What else may be wrong?

Re: reCaptcha v2 not working for me

Posted: Mon Oct 11, 2021 1:23 pm
by rvwilliams
Finally I have a working form. I had to make two changes:
Firstly my template was wrong. Instead of
<div class='g-recaptcha" data-sitekey='...my site key...'>
I should have had
<div data-cgbf-captcha data-sitekey='...my site key...'>
However even after this change the form would still submit without a recaptcha check. So the second change was to use SmartForms (thank you DIGI3) and change the tags to data-smtfm-xxx. This now works.

Re: reCaptcha v2 not working for me

Posted: Mon Nov 29, 2021 9:26 pm
by andrewvideouk
Yes the bug is still there in smartforms, I had to do the auto add. didnt work when I did manually add just the captcha one.