vb.net - asp.net watermark on page load -


here i'm trying watermark 2 textbox, supposedly username , password textbox. hang of it, using code:

 <asp:textbox id="tbusername" runat="server" cssclass="tb" width="170px" onfocus="if(this.value=='enter username'){this.value=''}"                                 onblur="if(this.value==''){this.value='enter username'}"></asp:textbox> 

and

 <asp:textbox id="tbpassword" runat="server" cssclass="tb" textmode="password" width="170px"                                 onfocus="if(this.value=='enter password'){this.value=''}" onblur="if(this.value==''){this.value='enter password'}"></asp:textbox> 

the problem is, can watermark pop-up clicking textbox first, while want them show when page first started. there anyway that? thank in advance help.

use html5's property placeholder whatemark

like below

 <asp:textbox id="tbpassword" runat="server" cssclass="tb" textmode="password" width="170px"                                 placeholder="your password"></asp:textbox> 

for use of property need not use external script or coding,just have put placeholder attribute in textbox


Comments