When I submit the form with Invalid input and try to resubmit form. then it show the Error ["timeout-or-duplicate"]
. I want to reset the recaptcha without to reload the page.
I tried with grecaptcha.reset()
. But it does not work for me. Can anyone help me?
3 Answers
I had the same issue but I fixed it. The javascript code that you have pasted in your front-end file (HTML file), should ONLY be executed when the entire HTML page completes loading. In Javascript we say when the DOM is ready -
So, in vanilla javascript you can use code similar to -
document.addEventListener("DOMContentLoaded", function(){
// Handler when the DOM is fully loaded
// Google recaptcha V3 Javascript code should be here
});
Or, if you are using jQuery -
$(document).ready(function() {
// Handler when the DOM is fully loaded
// Google recaptcha V3 Javascript code should be here
});
Hope this will fix the issue.
Check if your form is double submitted. Here is a jQuery code where you can see how to prevent the form from duplicationg the submit.
We have debugging this for some time now and I looks like the recaptcha expires after some time, our problem is that we trigger the execute() on load and it seems to expire then if the user wait about 3 minutes before sending the form. Will investigate this further..
What I can see is this a problem in the frontend, it's not a backend problem. We have checked that we just verify the recaptcha one in the backend so it's expires from the time we render the form to we check it in the backend.