<asp:TextBox TextMode="Password" ID="TxtBx_Password" runat="server" Width="175px" Text="Password" ForeColor="Gray"
onblur="WaterMarkPwd(this, event);" onfocus="WaterMarkPwd(this, event);"></asp:TextBox>
我正在使用此密码文本框并使用 WaterMarkPwd js 方法,如下所示,
<script type ="text/javascript">
function WaterMarkPwd(txtpwd, event)
{
var defaultText = "Password";
// Condition to check textbox length and event type
if (txtpwd .value.length == 0 & event.type == "blur")
{
//if condition true then setting text color and
//default text in textbox
txtpwd .style.color = "Gray";
txtpwd .value = defaultText;
}
// Condition to check textbox value and event type
if (txtpwd .value == defaultText & event.type == "focus")
{
txtpwd .style.color = "black";
txtpwd .value = "";
}
}
</script>
问题是,如果我将其应用于具有文本模式 =“文本”的文本框,那么它可以正常工作,但是当我将其更改为文本模式 =“密码”时,它会显示加密文本,因为我在方法中设置它defaultText = "Password";
如何解决希望您的建议