Link to home
Start Free TrialLog in
Avatar of lulu50
lulu50Flag for United States of America

asked on

to clear Textbox onclick

Hi,

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.

Thanks,
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

Avatar of BToson
BToson
Flag of United Kingdom of Great Britain and Northern Ireland image

Hi,
Try this.  onkeydown will not work here.
<asp:TextBox on ID="TxtKeywords" runat="server" Text="Enter Keywords" onclick="this.value='';" />
ASKER CERTIFIED SOLUTION
Avatar of BToson
BToson
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lulu50

ASKER

Thank you