Search code examples
jquerytooltip

How to use tooltip bootstrap in asp.net?


I use tooltip , but it's not work .

   <input type="text"  id="txt_name" />
<button id="bt_ok" >Ok</button>

 function CheckInput() {
            if ($("#txt_name").val() == '') {
                $('#txt_name').focus();
                $('#txt_name').tooltip({ placement: 'top', title: 'Please input name' });
               return false;
            }
           return true;
} 
$('#bt_ok').click(function (e) {
            if (!CheckInput) {
                return false;
            }
});

When i'm not type in textbox,it's focus to textbox but tooltip not show in top textbox . Thank you


Solution

  • You need to call the CheckInput function, now you are checking the function reference which will always be truthy

    $('#bt_ok').click(function (e) {
            if (!CheckInput()) {
                return false;
            }
    });