简体   繁体   中英

alternative for placeholder in order to work at internet explorer

Placeholder can't be used in internet explorer.

1) When i tested the 1ts one it works in chrome, firefox but does not work in internet explorer.

2) when i tested 2nd, it works well on chrome, firefox and also internet explorer.

The problem I'm facing here is when i add (ID="txtUserID") this to (2) it does not work on internet explorer. But i need the (ID="txtUserID") this in order to use it in the back-end.

Any solution for this?

****************1*******************

<asp:TextBox ID="txtUserID" CssClass="form-control" type="text" placeholder="Username " Width="100%" Height="36px" runat="server" Text="adminuser" MaxLength="16" />

****************2*******************

<asp:TextBox CssClass="form-control" Width="100%" Height="36px" MaxLength="16" Text="adminuser" runat="server" value="Username......" placeholder="Username" onfocus="if(this.value==this.defaultValue)this.value='';" onblur="if(this.value=='')this.value=this.defaultValue;"> </asp:TextBox>

Alternate to placeholder: Use onblur function of jquery and change value of text box accordingly.

 <!DOCTYPE html> <html> <body> Enter your name: <input id="#yourID" type="text" value="placeholder" onfocus="myFunction(this)" onblur="addPlaceHolder(this)"> <script> function myFunction(x) { x.value = ""; } function addPlaceHolder(thisEle){ if(thisEle.value=='Place Holder' || thisEle.value=='') thisEle.value='Place Holder'; } </script> </body> </html> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM