Results 1 to 2 of 2

Thread: Control textbox text on events

  1. #1
    Join Date
    Dec 2007
    Posts
    88
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Question Control textbox text on events

    Good day, Functions neeeded.

    I have a search textbox where I would like to display the "Search Keywords" in text of textbox when blank but when mousemove clear text.

    1. When textbox is blank then I would like to display text value "Search Key"
    2. Onmouseover & Focus: when text value "Search Key" then blank else valu
    3. OnMouseLeave / loosefocus: when text value blank then "Search Key" else value
    4. I would also like to change the font.

    Please Assist

  2. #2
    Join Date
    Dec 2007
    Posts
    88
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Hi, I found the below worked for me - not good coding.

    <script type="text/javascript" language="javascript">
    var EMPTY = "";

    function In()
    {
    var handle = document.getElementById("<%=TextBox1.ClientID%>").value;
    var initialText = "Process";

    if (handle == initialText)
    {
    document.getElementById("<%=TextBox1.ClientID%>").value = EMPTY;
    document.getElementById('<%=TextBox1.ClientID%>').style.fontStyle = "normal";
    }
    }

    function Out()
    {
    var handle = document.getElementById("<%=TextBox1.ClientID%>").value;
    var initialText = "Process";

    if (handle == EMPTY)
    {
    document.getElementById("<%=TextBox1.ClientID%>").value = initialText;
    document.getElementById('<%=TextBox1.ClientID%>').style.fontStyle = "italic";
    }
    }

    </script>

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •