using Water text mark in asp.net using javascript
this username Will hide when we Write Any thing in textbox
For this You need To Write the Following Code
function WaterMark(txtName, event) {
var defaultText = "Enter Username Here";
// Condition to check textbox length and event type
if (txtName.value.length == 0 & event.type == "blur") {
//if condition true then setting text color and default text in textbox
txtName.style.color = "black";
txtName.value = defaultText;
}
// Condition to check textbox value and event type
if (txtName.value == defaultText & event.type == "focus") {
txtName.style.color = "black";
txtName.value = "";
}
and write the Code also In text box Like this....
<asp:TextBox ID="txtName" runat="server" Text="Enter Username Here"
ForeColor="black" onblur= "WaterMark(this, event);"
onfocus = "WaterMark(this, event);" Width="161px"></asp:TextBox>
No comments:
Post a Comment