Click here to Skip to main content
15,921,660 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
XML
how to put default value in textbox and on keypress remove it


value="0" onfocus="if (this.value === '0') this.value = ''" onblur="if(this.value === '') this.value = '0';"

<asp:TextBox ID="txt_compvalue" runat="server" value="0" onfocus="if (this.value === '0') this.value = ''" onblur="if(this.value === '') this.value = '0';" Width="45%"></asp:TextBox>
Posted
Comments
OPees 2-Mar-14 23:20pm    
use placeholder.

 
Share this answer
 
Hi,

Try this:
ASP
<asp:TextBox id="TextBox1" Text="Default value" runat="server" onclick="this.value='';" onblur="this.value='Default value';"/>

Source: http://forums.asp.net/post/5098203.aspx[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900