繁体   English   中英

ASPX密码文本框

[英]ASPX Password textbox

默认情况下,密码字段框会屏蔽用户键入的所有文本**

我希望能够在密码字段框中显示一个字符串。

因此,在加载密码控件时,应该首先说“请输入您的密码”。

目前aspx显示为* ** * ***

我怎样才能做到最好?

干杯

使用TextMode。

<asp:TextBox ID="Password" runat="server" TextMode="Please enter your Password"  
onclick="this.value=''; this.type='password'; ">Password                                                    
</asp:TextBox>

要么

使用占位符。

对于EX:

<input type="password" placeholder="Please enter your Password">

你可以使用jquery来实现它:

HTML:

<input id="password" value="password" class="password-input" />

JS:

$('.password-input').bind('click', function() {
    if ($(this).val() === "Please enter your Password")
    {
       this.type = "password";
       $(this).val(''); 
    }
});

$('.password-input').bind('blur', function() {
    if ($(this).val() === "")
    {
       this.type = "text";
       $(this).val('Please enter your Password');
    }
});

的jsfiddle:

http://jsfiddle.net/V2Dh5/3/

您还可以查看以前有关同一事项的SO问题:

设置密码输入的默认值,以便可以读取

在IE 8中设置密码输入/场景/问题的默认值

asp.net文本框的默认值 - > TextMode =密码

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM