如何将此代码集成到以下形式的验证条件中:
$("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; }
});
答案 0 :(得分:0)
$(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();
}
}
});