Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Craig100 1136 posts 2523 karma points c-trib
    Oct 24, 2018 @ 18:47
    Craig100
    0

    ReCaptcha2 validation in Umbraco Forms

    umb 7.12.3 forms 7.0.4

    Have an Umbraco Form with a recaptcha2 control in it. It's set up correctly in that it communicates with Google and gives an output to grecaptcha.getResponse() when checked. Without being checked it allows the form to submit whether or not it's set as mandatory in the form set up. If the Umbraco Forms JS validation for it doesn't work out of the box, how do you hook this code into whatever Umbraco Forms is doing at submit to include it in the validation?

        $('.getmoreinformation form').validate({
        ignore: ".ignore",
        rules: {
            hiddenRecaptcha: {
                required: function () {
                    if (grecaptcha.getResponse() == '') {                       
                        return true;
                    } else {
                        return false;
                    }
                }
            }       
        },
        errorElement: "label",
        errorPlacement: function (error, element) {
            // Add the `help-block` class to the error element
            error.addClass( "help-block" );
    
            if (element.prop("type") === "checkbox") {
                error.insertAfter(element.parent("label"));
            } else {
                error.insertAfter(element);
            }
        }    
    });
    

    Any suggestions would be appreciated.

    Thnx

  • Craig100 1136 posts 2523 karma points c-trib
    Oct 25, 2018 @ 08:12
    Craig100
    1

    I see this is an old issue:-

    https://issues.umbraco.org/issue/CON-1552

    https://github.com/umbraco/Umbraco.Forms.Issues/issues/36

    If anyone has managed to integrate the client side into the UF validation schema I'd love to hear about it :)

Please Sign in or register to post replies

Write your reply to:

Draft