How to Clear TextBox Value When User Clicks Inside TextBox Using In Asp.Net C#

 Clear TextBox Value When User Clicks Inside TextBox 

If TextBox Assign Email Id Default Text Assigned  Enter Valid EmailId When Click Inside TextBox
 Clear the Validation Text Using in Asp.Net C#.



                                          DEMO






HTML CODING


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
   
    </div>
     
           Name
        <asp:TextBox ID="txtName" runat="server"

                            onclick="if (this.value == 'Enter Name') {this.value='' ;this.style.color = 'black'}" onblur="if(this.value.length==0) { this.value='Enter Name';this.style.color = 'grey'}"

      Width="275px" ForeColor="#999999">Enter Name</asp:TextBox>
     
        Email Id<asp:TextBox ID="txtEmailId" runat="server" onclick="if (this.value == 'Enter Email') {this.value='';this.style.color = 'black'}"  onblur="if(this.value.length==0) { this.value='Enter Email'; this.style.color = 'grey'}"

                            Width="275px" ForeColor="#999999" >Enter Email</asp:TextBox>

      
    </form>
</body>
</html>


First Add - New WebForm -  Select Textbox  Change Property







Next - Go - To - Source  - Select TextBox OnClick -  Write Default Letters Conditions






Next - Run[F5] - Default Text Show - Click Inside Clear Default Text 









0 comments:

Post a Comment