我试图使用JQuery Validation Plugin中的远程功能来检查电子邮件地址是否存在。我无法让它返回它被注册的状态。我使用提供的默认php类。我正在使用Jquery Latest
这是我的班级
<script type="text/javascript">
$.validator.setDefaults({
submitHandler: function() { alert("submitted!"); }});
$().ready(function() {
// validate signup form on keyup and submit
$("#form1").validate({
rules: {
user_pass: {
required: true,
minlength: 6
},
user_pass_confirm: {
required: true,
minlength: 6,
equalTo: "#user_pass"
},
email: {
required: true,
email: true,
remote: { url:"module/1.func.php",
type : "get",
data : { email : function() { return $("#email").val();
},
}
}
},
terms: "required"
},
messages: {
user_pass: {
required: "Please provide a password",
minlength: "Password must be at least 6 characters"
},
user_pass_confirm: {
required: "Please provide a password",
minlength: "Password must be at least 6 characters",
equalTo: "Eenter the same password as above"
},
email: {
required: "Enter your email address",
email: "Enter a valid email address",
},
terms: "Please accept our policies"
}
});
});
-----编辑 - 增加1.inc.php -----
$email = $_REQUEST['email'];
if($email=="me@god.com"){
$valid = 'false';
}else{
$valid = 'true';
}
echo $valid;
?>
-----编辑 - 改变了Jquery -----
我现在已将电子邮件规则更改为以下内容。如果电子邮件匹配,我会收到“请修复此字段”。
电子邮件:{ 要求:是的, 电子邮件:是的, remote:“module / 1.func.php”},
答案 0 :(得分:1)
将远程验证器更改为
remote: "module/1.func.php"
它已经通过get发送电子邮件并发送该字段值。