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

ReCaptcha-validation client-side not working

form

Solved by Mirko View solution

Started by Mirko 7 years ago · 1 replies · 2100 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 1425 5 months ago
Forms & Blueprints · by Hugo Oliveira, 6 months ago
0 218 6 months ago
Forms & Blueprints · by Flachy Joe, 7 months ago
9 313 7 months ago
Forms & Blueprints · by Augustus, 7 months ago
7 294 7 months ago
Forms & Blueprints · by Julien, 8 months ago
10 331 8 months ago