jquery - 使用 Parsley 的 Google reCaptcha 无法正常工作
问题描述
嗨,有一个页面,我希望在欧芹表单验证之后出现 recaptcha,但首先进行 recaptcha 验证,然后再次进行表单验证 recaptcha 出现
任何帮助将不胜感激。
<html>
<head>
<title>reCAPTCHA demo: Simple page</title>
<script src="http://parsleyjs.org/dist/parsley.js"></script>
<script src="https://www.google.com/recaptcha/api.js"></script>
</head>
<body>
<form action="?" method="POST" data-parsley-validate id="contactForm">
<input type="email" data-parsley-required />
<div class="g-recaptcha" data-sitekey="my_site_key"
data-callback="captchaCallback"></div>
<br/>
<input type="submit" value="Submit">
</form>
</body>
</html>
<script>
$('#contactForm').parsley().on('field:validated', function() {
var ok = $('#contactForm').find('.parsley-error').length === 0;
$('#contactForm').find('.bs-callout-warning').toggleClass('hidden', ok);
$('#contactForm .contact-success-msg').addClass('hide');
})
.on('form:submit', function() {
//ajax function
}
});
</script>
<script>
function hello() {
var a = $('form');
$(a).each(function() {
var b = $(this).find('.submit-contact-form');
$(b).unbind().click(function(e) {
e.preventDefault();
grecaptcha.reset();
grecaptcha.execute();
abc = $(this);
});
});
}
</script>
解决方案
只需将其添加到表单中。
数据-欧芹-排除=“输入[名称=g-recaptcha-response],输入[id=recaptcha-token]”
推荐阅读
- javascript - 在生成器上使用扩展语法时,为什么没有检索到返回值
- assembly - 将 Turbo Pascal 内联代码转换为 Object Pascal
- javascript - 如何使链接,导致自己,在整个项目中不可点击?拉拉维尔 8
- c# - 无法访问 XAML 代码隐藏中的继承属性
- amazon-web-services - 我可以为 AWS 上的多个 NAT 网关使用相同的出站 IP 吗?
- ruby-on-rails - 停止...跳过... 较少命令的摘要 标有 * 的命令前面可能有一个数字
- tensorflow - 在 TFX 中,是否可以用日期推断 Schema?
- java - java 15 jdeps --print-module-deps 不打印逗号分隔列表(windows 10,cmd)
- c# - 从非泛型静态类中的泛型重载方法中获取 RuntimeMethodInfo
- google-chrome - Chrome 如何在 macOS 上支持 webgl?