0

I have a text box in my aspx page. I need show its tooltip when and only when the text box is disabled/greyed out. How do I achieve this using JavaScript?

0

2 Answers 2

3

You can call this function where you enable/disable the textbox

function setToolTip()
{
    if(document.getElementById("myTextBox").disabled == true)
    {
        document.getElementById("myTextBox").title="ToolTip";
    }
    else
    {
        document.getElementById("myTextBox").title="";
    }
}
Sign up to request clarification or add additional context in comments.

Comments

0

Here is one way:

document.getElementById("<%=TextBox.ClientID%>").setAttribute('title','New Tooltip');

2nd way:

function DisplayToolTip()
        {
            document.getElementById('divToolTip').style.left = window.event.x;
            document.getElementById('divToolTip').style.top = window.event.y;

            document.getElementById('divToolTip').style.visibility = 'visible';
        }

        function HideToolTip()
        {
            document.getElementById('divToolTip').style.visibility = 'hidden';
        }

Now add the below HTML markup code:

    <span id="spanName" style="font-weight: bold;border: solid 2px red;" 
onmouseover="javascript:DisplayToolTip();"
        onmouseout="javascript:HideToolTip();">THIS IS THE SPAN
    </span>


   <div id="divToolTip" style="position: absolute; visibility: hidden;
   z-index: 20; background-color: white; border: solid 1px Blue;">
   This is ToolTip Text
   </div>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.