I am trying to use the remote method of the jquery validator plugin but even when return "true" is not valid, the field is still red.
I have already tried to put quotation marks as well as without quotation marks. It blinks green, but soon turns red, on the console I'm printing when it enters if or else, and it enters if, but not valid. Like you can see: https://youtu.be/m42-QZVVz_4
var link = "http://localhost/API/index.php/validaemail";
$("#btn_cadastro").click(function(){
$("#formcadastro").validate({
onkeyup: false,
submitHandler: function(form){
form.submit();
},
rules:{
nome:{
required : true,
maxlength: 100
},
senha:"required",
confirmar_senha:{
equalTo: "#senha"
},
email: {
required: true,
remote: {
url: link,
type: "GET",
dataType: "json",
data: {email: function() {return $("#email").val();}},
complete: function(data){
if(data.responseJSON.Status == 1){
console.log("TRUE");
console.log(data.responseJSON);
return true; // i try "true" already
}else{
console.log("FALSE");
console.log(data.responseJSON);
return false;
}
}
}
}
},
messages:{
email:{
required:"Insira um email",
email: "Insira um email valido",
remote: jQuery.validator.format("{0} já cadastrado")
}
}
});
});
I wish that when it entered true it would let register.