我想创建一个基于数据库值的特殊邮政编码验证。因此,我对AJAX检查值:ajax jquery表单验证总是验证错误
jQuery.validator.addMethod("validate_country_from", function(value, element)
{
$.ajax({
type: "POST",
url: "ajax.php",
data: "action=validate_countryzip&direction=1&zip=" +
escape(document.getElementById("zip_from").value) + "&country=" +
escape(document.getElementById("country_from").value),
async: false
}).done(function(msg)
{
if(msg == "true")
{
return true;
}
else
{
return false;
}
});
}, addressError);
而且我对这些规则的规则分配功能:
zip_from: {
required: true,
validate_country_from: true
},
country_from: {
required: true,
validate_country_from: true
},
Ajax请求工作正常,并且它完成同步的,返回的值也是正确的,但我的验证仍然告诉我这两个字段有错误。
我希望有人能帮助...