0
I’m validating the email using tooltip to display the message. If at first the guy puts registered email the search is made and displayed the message that the "Registered Email", if he changes the email to one that is not registered the message should be "Available Email", but even if he exchanges the email to available the message remains. How do I change it? Note: if the form is different (e-mail available) the message is displayed saying that the email is available, and if it changes to one that exists the message "E-mail available" is maintained. So my problem is being in the title.
//validação de email
$(function validateEmail() {
$('#Email').change(function () {
var url = '@Url.Action("ValidateEmail", "Ajax")';//url do controller que passará a informação
var email = $('#Email').val();
$.ajax({
type: 'POST',
url: url,
data: { email: email },
dataType: 'json',
success: function (data) {
if (data.success==true) {
$('.messageTooltip').tooltip({ title: "Email já cadastrado" });
//$('#MensagemEmail').text("Email Já Cadastrado");
$('#Email').focus();
}
if (data.success == false) {
$('.messageTooltip').tooltip({ title: "Email disponível" });
}
}
});
});
});//Fim da validação de email
As can be seen in the image below, the return is being executed correctly, and in the first was inserted an unregistered email, and in the second registered.
Are you sure that the
success
is false at any given time? And the second semantic condition is unnecessary, it would be better only withelse
.– BrTkCa
Yes, as you can see in the image I just put on having put if in place of Else, it was because I was testing even, had done with Else.
– Fabio Souza
Have you seen if you are entering the second if? put a console.log there and take the test
– JuniorNunes