[New reCAPTCHA] Reload recaptcha after failed submission

[New reCAPTCHA] Reload recaptcha after failed submission

  
Forge Component
(10)
Published on 2017-05-10 by leonardo.fernandes
10 votes
Published on 2017-05-10 by leonardo.fernandes

Hello.

I have a form with the New Recaptcha widget on it. When a user submits the form, we validate if there is anything wrong with the information submitted. If there is anything wrong, then the user enters the correct information and submits the form again, but then the Recaptcha fails because the page didn't reload and so the Recaptcha didn't reload.

Is there any solution to this? Thank you very much!



Hello Sandra,

You can try changing from Ajax Submit to Submit, that will reload the page if the user didn't insert the proper information and request a new Captcha.

Regards,

Cristiano

First of all, if you have only one Captcha on the page, you can reset it by using grecaptcha.reset().

If you have multiple forms and Captchas on the page, the process flow is much more complicated, but in the end you can reset it by using grecaptcha.reset(widget_id).

Please refer the documentation how to do it.

reCAPTCHA v2

Also, in both cases, you can try not to reset Captcha on every form validation fail. The approach is to do the Captcha verification after successful form validation, not before it. Reset the Captcha only on success or on any critical errors after the Captcha verification.