dasran rajlui dasran rajlui - 1 month ago 5x
ASP.NET (C#) Question

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?


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


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

    Enter your name: <input id="#yourID" type="text" value="placeholder" onfocus="myFunction(this)" onblur="addPlaceHolder(this)">

   function myFunction(x) {
    x.value = "";
function addPlaceHolder(thisEle){
if(thisEle.value=='Place Holder' || thisEle.value=='')
thisEle.value='Place Holder';