Tuesday, 22 October 2013

WaterMark Textbox using Java Script

WaterMark Textbox using Java Script : 

 JavaScript :

<script type = "text/javascript">
        var TextBoxText = "Enter Your Name";
        function WaterMark(txt, evt) {
            if (txt.value.length == 0 && evt.type == "blur") {
                txt.style.color = "gray";
                txt.value = TextBoxText;
            }
            if (txt.value == TextBoxText && evt.type == "focus") {
                txt.style.color = "black";
                txt.value = "";
            }
        }
</script>


   Name :
    <asp:TextBox ID="txtName" runat="server" Text = "Enter Your Name"
         ForeColor = "Gray" onblur = "WaterMark(this, event);"
         onfocus = "WaterMark(this, event);">
</asp:TextBox>
        <asp:Button  ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click"/>







No comments:

Post a Comment