to clear Textbox onclick

Posted on 2008-11-09
Last Modified: 2012-05-05

I have a textbox with a value (Enter Keywords)
what I want is when the user get to the page is to see the Enter Keyword
in the textbox and when the user clickon the text box it should clear the field.

Here's what I have.

<asp:TextBox ID="TxtKeywords" onkeydown="clearInput(this);" runat="server" Text="Enter Keywords"></asp:TextBox>

function clearInput(obj)


obj.value = ""; 


Open in new window

Question by:lulu50
    LVL 4

    Expert Comment

    Try this.  onkeydown will not work here.
    <asp:TextBox on ID="TxtKeywords" runat="server" Text="Enter Keywords" onclick="this.value='';" />
    LVL 4

    Accepted Solution

    Apologies, meant this!
    <asp:TextBox ID="TxtKeywords" runat="server" Text="Enter Keywords" onclick="this.value='';"></asp:TextBox>

    Author Closing Comment

    Thank you

    Featured Post

    Live: Real-Time Solutions, Start Here

    Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

    Join & Write a Comment

    Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now