WaterMark in ASP.Net TextBox using JavaScript
Watermark textbox are really useful to let the users to know the purpose of the textbox. Read my previous article - Creating Watermark TextBox in ASP.Net using JQuery to implement the feature using jQuery.
The following code snippet will help us doing this using JavaScript.
<head runat="server">
<title></title>
<script language="javascript">
function DoWaterMarkOnFocus(txt, text) {
if (txt.value == text) {
txt.value = "";
}
}
function DoWaterMarkOnBlur(txt, text) {
if (txt.value == "") {
txt.value = text;
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:textbox ID="txtSearch" Text="Search..." onfocus="DoWaterMarkOnFocus(this,'Search...')" onblur="DoWaterMarkOnBlur(this,'Search...')" runat="server"></asp:textbox>
|