Forums

Forums / General Discussions / Add captcha to submit button on form flow form

Add captcha to submit button on form flow form

3 posts, 1 answered
  1. Mike Cohen
    Mike Cohen avatar
    31 posts
    Registered:
    10 Aug 2021
    04 Jan
    Link to this post
    What is the prescribed method to alter the submit button on a form flow form?  we want our final form flow form to have captcha approval when the submit button is clicked..  For all our non form flow forms we have a submit button widget template that includes captcha.  What would be the best approach to use this widget or implement something similar for a form flow form? 
  2. Mike Cohen
    Mike Cohen avatar
    31 posts
    Registered:
    10 Aug 2021
    Answered
    05 Jan
    Link to this post
    Answering my own question.  

    Put the captcha in a content block 
       <div class="g-recaptcha" data-sitekey="myrecap key"></div>

    Added this script to run on pre-validate. 
        $(document).on("tpc:pre-validate", function (event, form, sender) {
        if (grecaptcha.getResponse() !== '') {
        // recaptcha valid
        } else {
            event.message = "reCaptcha not valid.";
            return false;
        }
        
    });
  3. Rawdon Edghill
    Rawdon Edghill avatar
    76 posts
    Registered:
    16 Dec 2020
    08 Jan
    Link to this post
    Hi Mike,

    Sorry for the late reply. 

    I am glad you were able to figure it out. 

    I was going to tell you to copy the reCaptcha parts from the template into the form.
    The code uses pre-validate to check it. This will still work if moved.

    Regards,

    Rawdon
3 posts, 1 answered