Definition: Clear TextBox value.
To clear TextBox value we will use onclick() event of TextBox. onclick() we will call user defined javascript function.
Code:
1. First put TextBox control on page.
<asp:TextBox ID="TextBox1" runat="server" Text="Your Text Here" onclick="javascript:Clear(this);"></asp:TextBox>
2. Now write onclick() event as shown above.
3. Now in Head tag we will write javascript function.
<head runat="server">
<title>Form validation</title>
<script language="javascript" type="text/javascript">
function Clear(txt)
{
txt.value="";
}
</script>
</head>
4. When user click inside the TextBox its value will be clear.
To clear TextBox value we will use onclick() event of TextBox. onclick() we will call user defined javascript function.
Code:
1. First put TextBox control on page.
<asp:TextBox ID="TextBox1" runat="server" Text="Your Text Here" onclick="javascript:Clear(this);"></asp:TextBox>
2. Now write onclick() event as shown above.
3. Now in Head tag we will write javascript function.
<head runat="server">
<title>Form validation</title>
<script language="javascript" type="text/javascript">
function Clear(txt)
{
txt.value="";
}
</script>
</head>
4. When user click inside the TextBox its value will be clear.
No comments:
Post a Comment