I'm doing email validation using toolTip to display the message. If the first one puts the registered e-mail the search is made and the message is displayed that the "Registered E-mail", if it changes the e-mail to one that is not registered the message should be "E-mail available ", but even if he switches the email to available the message remains. How do I change it? Note: if the form is different (email available) the message is displayed saying that the email is available, and if it changes to an existing "Available mail" message is retained. 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 email not registered, and the second registered.