On click default text of text box vanishes & on clicking out side some where default text appers in text box

In this tutorial i will show how we can vanish default text in textbox on click & appers ones we can out side somewhere like happens in search boxs of the many professional websites.

For this we just have to add two events to the text box.

Take one text box & go to the source of the text box.
code of textbox will look something like this....
 <asp:TextBox ID="TextBox1" runat="server">asp:TextBox>

We just have to add this two thing to text box & it will work as i said above....

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

where "SEARCH" is default text of the textbox.
after adding this code of text box will look something like this....

<asp:TextBox ID="searchTextDown" runat="server"  
onfocus
="if(this.value =='SEARCH')this.value='';"
onblur="if(this.value=='')this.value='SEARCH';">SEARCH
</
asp:TextBox>

0 comments:

Post a Comment