Asp.net ASPX密码文本框
默认情况下,密码字段框屏蔽了用户键入的所有文本 我希望能够在密码字段框中显示字符串 因此,在加载密码控件时,最初应该显示“请输入您的密码” 当前aspx显示为********* 我如何才能最好地实现这一点 干杯使用文本模式Asp.net ASPX密码文本框,asp.net,.net,textbox,passwords,Asp.net,.net,Textbox,Passwords,默认情况下,密码字段框屏蔽了用户键入的所有文本 我希望能够在密码字段框中显示字符串 因此,在加载密码控件时,最初应该显示“请输入您的密码” 当前aspx显示为********* 我如何才能最好地实现这一点 干杯使用文本模式 <asp:TextBox ID="Password" runat="server" TextMode="Please enter your Password" onclick="this.value=''; this.type='password'; ">Pa
<asp:TextBox ID="Password" runat="server" TextMode="Please enter your Password"
onclick="this.value=''; this.type='password'; ">Password
</asp:TextBox>
密码
或
使用占位符
例如:
<input type="password" placeholder="Please enter your Password">
您可以使用jquery实现它: HTML:
<input id="password" value="password" class="password-input" />
$('.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:
<input id="password" value="password" class="password-input" />
$('.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');
}
});
您还可以看到前面关于同一事物的SO问题:
在问题中添加文本框标记/html。这不是密码文本框。我希望在用户键入密码时能够显示被屏蔽的密码