[英]ReCaptcha v2 client side events
Does ReCaptcha v2 expose any client side events? ReCaptcha v2会暴露任何客户端事件吗? I am looking specifically to identify when the Captcha response has been returned once the box is ticked, so I can reveal the "Continue" button below.
我正在寻找具体的方法来确定一旦勾选方框后何时返回了Captcha响应,我就可以显示下面的“继续”按钮。
Without this it is possible for the user to click the checkbox then quickly click the submit button before the captcha response is back. 如果没有这个,用户可以单击复选框,然后在验证码响应返回之前快速单击提交按钮。
I could possible add my own click event handler to the class recaptcha-checkbox-checkmark
and poll the visiblity of the tick, I just wondered if there was a simpler way to do this? 我可以将我自己的click事件处理程序添加到类
recaptcha-checkbox-checkmark
并轮询tick的visiblity,我只是想知道是否有更简单的方法来执行此操作?
$(".recaptcha-checkbox-checkmark").click(function() {
//...Poll for visibility of tick
});
Another solution is to set data-callback
directly on the g-recaptcha
div, like this 另一种解决方案是直接在
g-recaptcha
div上设置data-callback
,就像这样
<script type="text/javascript">
var imNotARobot = function() {
console.info("Button was clicked");
};
</script>
<div class="g-recaptcha" data-callback="imNotARobot" data-sitekey="key"></div>
You can configure reCAPTCHA to give a callback on successful validation using the data-callback attribute on the g-recaptcha tag or via the 'callback' parameter if using explicit rendering. 您可以配置reCAPTCHA以使用g-recaptcha标记上的data-callback属性成功验证回调,或者如果使用显式呈现则通过'callback'参数进行回调。
See https://developers.google.com/recaptcha/docs/display#render_param 请参阅https://developers.google.com/recaptcha/docs/display#render_param
Example using explicit rendering: 使用显式渲染的示例:
var myCallback = function(val) { console.log(val); };
grecaptcha.render(
document.getElementsById('my-recaptcha-placeholder'),
{
callback: myCallback,
sitekey: mySiteKey
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.