I use below code to show default watermark in textbox
<script type="text/javascript">
var defaultText = "Type here";
function WaterMark(txt, evt) {
if (txt.value.length == 0 && evt.type == "blur") {
txt.style.color = "#b1b1b1";
txt.value = defaultText;
}
<asp:TextBox ID="Txtsearch" runat="server" CssClass="txtseA" Text="Type here"
ForeColor="#b1b1b1" onblur="WaterMark(this, event);" onfocus="WaterMark(this, event);"></asp:TextBox>
if (txt.value == defaultText && evt.type == "focus") {
txt.style.color = "black";
txt.value = "";
}
}
</script>
now I have other textbox that I want put other watermark text on it so I worte below code
<script type="text/javascript">
var defaultText = "type in english";
function WaterMark(txt, evt) {
if (txt.value.length == 0 && evt.type == "blur") {
txt.style.color = "#b1b1b1";
txt.value = defaultText;
}
<asp:TextBox ID="TxtEnglish" runat="server" CssClass="txtseA" Text="Type in english"
ForeColor="#b1b1b1" onblur="WaterMark(this, event);" onfocus="WaterMark(this, event);"></asp:TextBox>
if (txt.value == defaultText && evt.type == "focus") {
txt.style.color = "black";
txt.value = "";
}
}
</script>
but it doesn't work
it just work for one textbox when I add two javacode to show watermark on textbox it doesn't work
what should I do?
Best regards
neda