我正在验证注册页面上的表单,除了电子邮件验证有点碰到和错过之外,一切正常。表单不能在电子邮件JSON验证后提交
它工作正常,如果我只是验证它,以确保它是一个实际的电子邮件地址,但是当我尝试添加一个检查,看看它是否在使用以及我遇到问题。
验证本身工作正常,但表单一旦验证且未使用就不会提交。
这工作,并提交表单:
if(filter.test(a)){
email.removeClass("field_error");
emailInfo.text("");
emailInfo.removeClass("error");
return true;
}
这工作,但形式不提交:
if(filter.test(a)){
$.post('php/availability.php',{email: $('#email').val()}, function(emaildata){
if(emaildata.exists){
email.addClass("field_error");
emailInfo.text("(Email address in use)");
emailInfo.addClass("error");
} else {
email.removeClass("field_error");
emailInfo.text("");
emailInfo.removeClass("error");
return true;
}
}, 'JSON');
}
我难倒。
什么是回来的emaildata? –
它返回'存在'。确切地说{“exists”:true}。 – Adam
如果它返回'{“exists”:true}',那么您的电子邮件地址正在使用中,并且表单不应该提交。也许我的理解不正确。 –