Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Forms & Blueprints

ReCaptcha-validation client-side not working

form

Solved by Mirko View solution

Started by Mirko 7 years ago · 1 replies · 2003 views
7 years ago

Hey, I have the same problem as the guy in this post: /forum/archive/recaptcha-not-validated-client-side-or-how-to-deal-with-form-errors-t9025

I am using Google ReCaptcha in my modular form template.
The validation of the ReCaptcha is perfectly working on server-side, but I can't get it run on client-side. So the user won't get any failure message before submitting the form.

It would be much nicer, if the user would get a message before sending the form, in which he is asked to fill out the recaptcha.

Thank you!

7 years ago Solution

I found a solution. Not the cleanest but it works (the ID of my form is "contact-form"):

JS
    var form = document.getElementById('contact-form');
    form.addEventListener("submit", function(event){
            if (grecaptcha.getResponse() === '') {
                event.preventDefault();
                alert('Bitte füllen Sie das ReCaptcha aus.');
            }
        }
        , false);

Suggested topics

Topic Participants Replies Views Activity
Forms & Blueprints · by Ton Haarmans, 5 years ago
13 1135 4 months ago
Forms & Blueprints · by Hugo Oliveira, 5 months ago
0 60 5 months ago
Forms & Blueprints · by Flachy Joe, 6 months ago
9 132 6 months ago
Forms & Blueprints · by Augustus, 7 months ago
7 108 7 months ago
Forms & Blueprints · by Julien, 7 months ago
10 127 7 months ago