javascript to disappear text from the textBox
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: javascript to disappear text from the textBox

  1. #1
    Join Date
    May 2006
    Posts
    35

    Thumbs up javascript to disappear text from the textBox

    HI all javascript brains,

    i have a text box with some default text in aspx page.. initially i want the color of the text to be silver along with the textbox border in silver. now when i click inside the textBox i want the default text in the textBox to disppear... and whatever i write should be black in color..
    i am very new in javascript and asp.net.. can somebody help me out

  2. #2
    Join Date
    Dec 2005
    Location
    Waterloo ON
    Posts
    545

    Re: javascript to disappear text from the textBox

    You can add the input control like:
    PHP Code:
    <input id="Text1" style="color: silver" type="text" value="initial text" onfocus="inputText1();" /> 
    and the script code would be
    Code:
    function inputText1()
    {
    	event.srcElement.value = ''; // only for IE
    	event.srcElement.style.color = 'black';
    }
    Hope it helps.

  3. #3
    Join Date
    Sep 2006
    Posts
    16

    Re: javascript to disappear text from the textBox

    server contol like
    <INPUT id="txtName" onclick="return fnDisappear();" onchange="return fnselec();" type="text" value="Mahendra">


    and javascript like


    function fnDisappear()
    {
    document.getElementById("txtName").value="";
    }

    function fnselec()
    {

    document.getElementById("txtName").style.color="red";
    }

  4. #4
    Join Date
    Jun 2005
    Posts
    11

    Re: javascript to disappear text from the textBox

    good help
    a common apn.net & vb.net developer

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center