Jquery - 需要使用Captcha的帮助

时间:2012-06-15 10:10:03

标签: jquery validation

任何人都可以告诉我如何为下面的验证码编写自定义验证器吗?我是jquery的新手,并没有编写任何自定义验证器。我需要使用此自定义验证器以及默认验证器。我尝试写作,但它没有用。请帮忙

challengeField = $("input#recaptcha_challenge_field").val();
responseField = $("input#recaptcha_response_field").val();
var html = $.ajax({
type: "POST",
url: "recaptcharesponse.jsp",
data: "recaptcha_challenge_field=" + challengeField + "&recaptcha_response_field=" +     responseField,
async: false
}).responseText;
//console.log( html );
$("#prtCnt").html("");
return true;
} else {
$("#prtCnt").html("<font color='#D31145'>Please try again.The characters you entered     didn't match the word verification</font>");   
Recaptcha.reload();                                         
return false;
}

由于

1 个答案:

答案 0 :(得分:0)

        challengeField = $("input#recaptcha_challenge_field").val();
        responseField = $("input#recaptcha_response_field").val();

        $.ajax({
        type: "POST",
        async: false,
        url: "recaptcharesponse.jsp",
data: {"recaptcha_challenge_field" :challengeField,"recaptcha_response_field":responseField),
        success:function(msg){
            if(msg == "something from server that captcha is ok"){
              //catcha is ok do wat you want
            }else{
            $("#prtCnt").html("<font color='#D31145'>Please try again.The characters you  entered  didn't match the word verification</font>");   
        Recaptcha.reload();
    }

    },error:function(){


    }

        });