<script type="text/javascript">
$().ready(function() {
jQuery.validator.addMethod("captcha", function(value, element) {
$.ajax({ url: "verifyCap.php",
type: "GET",
data: "txtCaptcha="+value,
success:
function(msg) {
if(msg == "true")
return true; // already exists
return false;
}
});
},"");
// validate signup form on keyup and submit
$("#signupForm").validate({
rules: {
title: "required",
contactname: "required",
email: {
required: true,
email: true
},
comment: "required",
txtCaptcha:{
required: true,
captcha: true
}
},
messages: {
contactname: "Please enter your contact name",
email: "Please enter a valid email address",
comment: "Please enter your system requierment",
txtCaptcha: {
required:"Please enter verification code",
captcha: "The verification code is incorrect"
}
}
});
});
我verifyCap.phpPHP jQuery的远程验证问题
<?php
session_start();
if ($_SERVER ["REQUEST_METHOD"] != "GET")
die ("You can only reach this page by posting from the html form");
if (($_GET ["txtCaptcha"] == $_SESSION ["security_code"]) && (! empty ($_GET ["txtCaptcha"]) && ! empty ($_SESSION ["security_code"]))) {
echo "true";
} else {
echo "false";
}
?>
我的问题可能是由于响应格式是不是真的还是假的,但是我打印出整个verifyCap代码。任何人都可以帮忙
这是你与你的形式做的唯一验证更多信息?或者还有其他服务器端验证? – KyleWpppd 2011-06-10 11:26:44