我尝试使用 JQuery Validation Plugin 中的远程功能来检查电子邮件地址是否存在。我无法让它返回它正在注册的状态。我正在使用提供的默认 php 类。我正在使用 Jquery 最新
这是我的课
<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--
我现在已将电子邮件规则更改为以下内容。如果电子邮件匹配,我会在输入电子邮件时收到“请修复此字段”。
电子邮件:{ 必需:true,电子邮件:true,远程:“module/1.func.php”},