Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net ASPX密码文本框_Asp.net_.net_Textbox_Passwords - Fatal编程技术网

Asp.net 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

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

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

因此,在加载密码控件时,最初应该显示“请输入您的密码”

当前aspx显示为*********

我如何才能最好地实现这一点

干杯

使用文本模式

<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。这不是密码文本框。我希望在用户键入密码时能够显示被屏蔽的密码