Skip to content
Advertisement

reCaptcha V3 fails validation on first form submission only

I am trying to set up reCaptcha v3 and it sort of works. For some reason the first time I submit the form it fails but from the second submit onwards it is fine. I can’t figure out why this is happening?

JavaScript

PHP

JavaScript

When I submit the form the first time, I get the validation error but my score is 0.9.

Advertisement

Answer

Why you have added “!” with “$responseData->score”? you may need to replace your condition with the following:

Replace this:

JavaScript

With this one:

JavaScript

P.S: Following code takes few seconds to properly load and get a “captcha-reponse” code, so you may need to disable all submit button and wait till you got a “captcha-reponse” to enable the submit button in form or you needs to implementent another way to delay the submit to execute only once you got a “captcha-response” code otherwise you will keep getting “missing-input-response” error message

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement