[英]ASPX Password textbox
By default, the password fieldbox masked all the text the user typed as ** . 默认情况下,密码字段框会屏蔽用户键入的所有文本** 。
I want to be able to display a string on the Password field box. 我希望能够在密码字段框中显示一个字符串。
So it should says "Please enter your Password" initially when the password control is loaded. 因此,在加载密码控件时,应该首先说“请输入您的密码”。
Currently aspx showing it as * ** * *** 目前aspx显示为* ** * ***
How can i best achieve this? 我怎样才能做到最好?
Cheers 干杯
Use TextMode. 使用TextMode。
<asp:TextBox ID="Password" runat="server" TextMode="Please enter your Password"
onclick="this.value=''; this.type='password'; ">Password
</asp:TextBox>
or 要么
Use placeholder. 使用占位符。
For EX: 对于EX:
<input type="password" placeholder="Please enter your Password">
You can achieve it using jquery: 你可以使用jquery来实现它:
HTML: HTML:
<input id="password" value="password" class="password-input" />
JS: 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: 的jsfiddle:
http://jsfiddle.net/V2Dh5/3/ http://jsfiddle.net/V2Dh5/3/
You can also see previous SO questions about the same thing: 您还可以查看以前有关同一事项的SO问题:
Set default value of a password input so it can be read 设置密码输入的默认值,以便可以读取
Set Default Value Of A Password Input / A Scenario / Issue in IE 8 在IE 8中设置密码输入/场景/问题的默认值
default value for asp.net textbox -> TextMode = password asp.net文本框的默认值 - > TextMode =密码
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.