ysa*_*uel 2 forms jquery recaptcha
我的网络中有一个表单,但我一直在收到一些跨度,所以我添加了 Google RecaptchaV2 并停止了跨度,但我想禁用提交按钮,直到检查了 Recaptcha 并且用户证明这是人类。
RecaptchaV2 在 Iframe 内运行,如何读取元素或属性以禁用提交?
在 Iframe 内部有一个跨度,一旦验证更改内容:从:
<span id="recaptcha-accessible-status">Recaptcha requires verification</span>
到:
<span id="recaptcha-accessible-status">You are verified</span>
Run Code Online (Sandbox Code Playgroud)
所以阅读我认为可能可以使用 Jquery 禁用/启用提交按钮,尝试使用 content() 读取它但无法访问 iframe 内容,有什么想法吗?
谢谢!
ysa*_*uel 13
这是答案,这只是为了禁用/启用检查提交按钮:
使其在一页中使用不同的表单但未经测试,欢迎提出任何建议/更改。
称呼:
<div class="g-recaptcha" data-sitekey="KEY-HERE" data-callback="correctCaptcha"></div>
<script type="text/javascript" src="https://www.google.com/recaptcha/api.js?hl=en"></script>
Run Code Online (Sandbox Code Playgroud)
该数据回调=“correctCaptcha”是主片。
js:
$("form").each(function() {
$(this).find(':input[type="submit"]').prop('disabled', true);
});
function correctCaptcha() {
$("form").each(function() {
$(this).find(':input[type="submit"]').prop('disabled', false);
});
}
Run Code Online (Sandbox Code Playgroud)