gpt4 book ai didi

javascript - 在表单验证中包含验证码

转载 作者:行者123 更新时间:2023-11-28 06:11:20 27 4
gpt4 key购买 nike

如何将此代码集成到以下形式的验证条件中:

$("form").clientSideCaptcha({
input: "#captchaText",
display: "#captcha",
pass : function() { alert("Passed!"); return false; },
fail : function() { alert("Please enter the text shown below");
document.contactForm.textcaptcha.focus();
return false; }
});

最佳答案

$(document).ready(function() {
$("#form").submit(function(event) {
//check for validCaptcha
var validCaptcha = $("#form").clientSideCaptcha({
input: "#captchaText",
display: "#captcha",
pass: function() {
return true;
},
fail: function() {
document.contactForm.textcaptcha.focus();
return false;
}
});
//invalid captcha - stop form submission
if (!validCaptcha) {
event.preventDefault();
}
}
});

关于javascript - 在表单验证中包含验证码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36362780/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com