Change Title to display tooltip

0

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.

    
asked by anonymous 18.12.2016 / 18:25

1 answer

1

To change the tooltip you can do as soon as it works ^^, it gets lost the way you are doing.

$('#batata').tooltip({ title: "Email já cadastrado" })

setTimeout(function(){
  $('#batata').attr("data-original-title", "batata")
},3000)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><linkrel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" />
<script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script><br><br><br><br><br><br><inputid="batata" />
    
19.12.2016 / 13:55