Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
52
rated 0 times [  53] [ 1]  / answers: 1 / hits: 15845  / 8 Years ago, fri, september 16, 2016, 12:00:00

Is there a way to programmatically enable/disable Google's reCaptcha widget? The purpose for this would be to prevent a user from clicking the I'm not a robot checkbox prematurely.


More From » jquery

 Answers
8

I found a solution thanks to this answer.



Add this CSS:



.disabled-element {
opacity: 0.65;
pointer-events: none;
}


Add the disabled-element class to the div containing the reCaptcha element:



<script>
var onloadCallback = function() {
alert(grecaptcha is ready!);
};
</script>

<div class=disabled-element id=captcha></div>
...
<script src=https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit async defer></script>


And finally, whenever you're ready to enable the reCaptcha element, remove the class:



$(#captcha).removeClass(disabled-element);

[#60695] Wednesday, September 14, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
mariann

Total Points: 201
Total Questions: 133
Total Answers: 107

Location: Czech Republic
Member since Thu, Aug 11, 2022
2 Years ago
;