我在使用 jquery Validate 插件验证此表单时遇到了一些问题,当响应有效时我没有得到任何响应,而且我不知道为什么...这是 html:
<form id="signin_form" action="" method="post">
<div id="recaptcha_widget" style="display:none">
<div id="recaptcha_image"></div>
<div class="recaptcha_only_if_incorrect_sol" style="color:red">Incorrect please try again</div>
<p><span class="recaptcha_only_if_image">Enter the <br />words above:</span>
<span class="recaptcha_only_if_audio">Enter the numbers you hear:</span>
<span><input type="text" id="recaptcha_response_field" name="recaptcha_response_field" /></span></p>
<div class="get_another_captcha"><a href="javascript:Recaptcha.reload()">Get another CAPTCHA</a></div>
<div class="recaptcha_only_if_image"><a href="javascript:Recaptcha.switch_type('audio')">Get an audio CAPTCHA</a></div>
<div class="recaptcha_only_if_audio"><a href="javascript:Recaptcha.switch_type('image')">Get an image CAPTCHA</a></div>
<div class="help"><a href="javascript:Recaptcha.showhelp()">Help</a></div>
</div>
<script type="text/javascript"
src="http://www.google.com/recaptcha/api/challenge?k=public_key">
</script>
<noscript>
<iframe src="http://www.google.com/recaptcha/api/noscript?k=public_key"
height="300" width="500" frameborder="0"></iframe><br>
<textarea name="recaptcha_challenge_field" rows="3" cols="40">
</textarea>
<input type="hidden" name="recaptcha_response_field"
value="manual_challenge">
</noscript>
<p><span></span><span> <input type="submit" value="Send" class="btn-submit" /> </span></p>
</form>
这是javascript:
$("#signin_form").validate({
rules: {
recaptcha_response_field: {
required: true,
remote: {
url:"verify.php",
type:"post",
async:false,
data: "recaptcha_challenge_field=" + $('#recaptcha_challenge_field').val() + "&recaptcha_response_field=" + $('#recaptcha_response_field').val()
}
}
},
messages: {
recaptcha_response_field: {
required: "*",
remote: "Invalid captcha"
}
}
});
和 verify.php 如下:
require_once('recaptchalib.php');
$privatekey = "private_key";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
echo "false";
}
else{
echo "true";
}
有谁知道为什么?,我似乎无法找到我一直在努力尝试的问题..,不知道为什么当验证码正确时不会发生任何事情......提前非常感谢