B
B
BonBon Slick2017-10-18 19:03:00
Google
BonBon Slick, 2017-10-18 19:03:00

How to catch the Google reCaptcha cancellation event, what if the user suddenly canceled the recaptcha input?

The bottom line is that there is a sending using ajax.
There is a sendingForm variable that prevents the user from multiple clicks on the "send" form button.
We set it before sending, as we check if true, return; if not, it continues to execute the code where we call the recaptcha, and here is the stupor.
If the user canceled the recaptcha, just as accidentally, missed the window or something else, then our sendingForm variable is still == true and the user cannot send the form already, because we are checking if the form is being sent before sending it.
Our code that sets the verification variable to sendingForm = false is in the callback function to the recaptcha.
If the user sent a response, clicked on the captcha test, failed it or passed, we get everything in the callback function and work with the answer there.

validate: function () {
                if (this.formSending) return;
                // validate form data
                this.$validator.validateAll().then((result) => {
                    if (grecaptcha) {
                        this.formSending = true;
                        grecaptcha.execute();
                    }
                });
            },

The captcha itself is here, and I don't see a function that will be called in case the window is closed or canceled
https://developers.google.com/recaptcha/docs/invisible
So how do you know if the user has canceled the captcha?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question