Change Title to display tooltip

Asked

Viewed 963 times

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. inserir a descrição da imagem aqui

  • Are you sure that the success is false at any given time? And the second semantic condition is unnecessary, it would be better only with else.

  • 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.

  • Have you seen if you are entering the second if? put a console.log there and take the test

1 answer

1


To change the tooltip you can do so 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>
<link rel="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>
<input id="batata" />

Browser other questions tagged

You are not signed in. Login or sign up in order to post.