本文介绍了使用textmode作为密码的水印文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当textmode是框中的*密码时,如何为文本框显示水印?

How to make watermark visible for a textbox when textmode is Password insted of "*" in the box?

推荐答案

<script language="javascript" type="text/javascript">
                   function WaterMark(txtName, event) {
                       var defaultText = "Enter Username Here";

                       if (txtName.value.length == 0 & event.type == "blur") {

                           txtName.style.color = "Gray";
                           txtName.value = defaultText;
                           txtName.setAttribute("type", "input");
                       }

                       if (txtName.value == defaultText & event.type == "focus") {
                           txtName.style.color = "black";
                           txtName.value = "";
                       }
                   }

                   function myFunction(txtName, event) {
                       txtName.setAttribute("type", "Password");
                   }
               </script>
               <asp:TextBox ID="txtUserName" runat="server" Text="Enter Username Here" ForeColor="Gray"
                   onblur="WaterMark(this, event);" onfocus="WaterMark(this, event);" onkeypress="myFunction(this, event)" />


<![CDATA[<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>]]>
<asp:scriptmanager id="MainScriptManager" runat="server" xmlns:asp="#unknown" />



<div id="watermarkextender">
        <asp:TextBox ID="txtwatermark" runat="server" placeholder="Password" TextMode="Password"></asp:TextBox>
        <asp:TextBoxWatermarkExtender ID="waterExten" runat="server" TargetControlID="txtwatermark" WatermarkText="Passwork"></asp:TextBoxWatermarkExtender>
    </div>



谢谢你。


Thank u.


这篇关于使用textmode作为密码的水印文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 02:33