CMS Made Simple Forums
https://forum.cmsmadesimple.org/

How to install Recaptcha on CGBetterForm
https://forum.cmsmadesimple.org/viewtopic.php?f=34&t=80276
Page 1 of 1

Author:  Mich-adg [ Tue Mar 05, 2019 11:16 am ]
Post subject:  How to install Recaptcha on CGBetterForm

Hi,
i'm trying to install a Recaptcha (or Invisible Recaptcha) on a CG BetterForm, but with Captcha module active or not (code pasted in the templates directly) i can't achieve it.
It seems that the submit function doesn't take care at the Captcha state.
If anybody has an example of working integration... !!
Thanks for help !

Author:  DIGI3 [ Tue Mar 05, 2019 2:52 pm ]
Post subject:  Re: How to install Recaptcha on CGBetterForm

I'd be happy to help you out with this directly if you get stuck, but I think you just need to add the default validators. (Validation tab, click on "auto add validations" then save your form.

Author:  Mich-adg [ Tue Mar 05, 2019 5:26 pm ]
Post subject:  Re: How to install Recaptcha on CGBetterForm

Hi, thanks for replying !

I got these validators yet :
Detect HTML tags in form input
Validate the value of select fields
Validate that all required fields are present
Ensure a reasonable value for all email fields

But i can still send the form without checking the box " i'm not a robot " from recaptcha.

My Form template:
Code:
<form>

  <div>
     <label for="myname">Name</label>
     <input id="myname" class="form-control" name="name" value="{$form_data->name}" required/>
  </div>

  <div>
     <label for="myemail">Email</label>
     <input id="myemail" class="form-control" type="email" name="email" value="{$form_data->email}" required/>
  </div>

  <div>
     <label for="comments">Comments</label>
     <textarea id="comments" class="form-control" name="comments" required>{$form_data->contents}</textarea>
  </div>

  <div class="g-recaptcha" data-sitekey="mykey"></div>

  <div>
    <button type="submit" class="fdorange">Send</button>
  </div>
</form>



The div containing the captcha :
Code:
<div class="g-recaptcha" data-sitekey="mykey"><div style="width: 304px; height: 78px;"><div><__iframe src="https://www.google.com/recaptcha/api2/anchor?ar=1&amp;k=...></__iframe></div><textarea id="g-recaptcha-response" name="g-recaptcha-response" class="g-recaptcha-response" style="width: 250px; height: 40px; border: 1px solid rgb(193, 193, 193); margin: 10px 25px; padding: 0px; resize: none; display: none;"></textarea></div></div>


In the head:
Code:
<__script__ src="https://www.google.com/recaptcha/api.js" async="" defer=""></__script>


Is something missing? ::)

Author:  DIGI3 [ Tue Mar 05, 2019 5:31 pm ]
Post subject:  Re: How to install Recaptcha on CGBetterForm

Oh I didn't notice you weren't using the Captcha module. No idea then.

Author:  Mich-adg [ Tue Mar 05, 2019 5:48 pm ]
Post subject:  Re: How to install Recaptcha on CGBetterForm

I retried with the Captcha Module on, and same result ! I can send the form without checking the box :s

Author:  DIGI3 [ Tue Mar 05, 2019 5:59 pm ]
Post subject:  Re: How to install Recaptcha on CGBetterForm  [DONE]

With the Captcha module installed there's a few steps you have to do:
-configure the Captcha module
-edit your CGBF form template to include the captcha tag and error display items (see the cgbf docs and/or the sample form templates)
-re-add the the auto validations. If the captcha tag (not captcha code, but the cgbf-specific captcha tag) is detected in your form template, the captcha validation will be added.

Author:  Mich-adg [ Tue Mar 05, 2019 8:06 pm ]
Post subject:  Re: How to install Recaptcha on CGBetterForm

Oh, it works now with your steps to do! Many many thanks !! ;)

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/