我希望在密码字段中显示星号而不是没有值。当我将字段设置为type=text时,我可以看到纯文本。当我将类型设置为密码时,我得到的是空白字段。有没有办法将值显示为星号?
<input type="text" id="txtPwd" runat="server" />
这就是我的领域。提前谢谢你,Laziale
发布于 2013-05-01 06:03:21
您可以使用HTML5 placeholder
属性:
<input type="password" placeholder="●●●●●●●●●">
示例:http://jsfiddle.net/AJ2kn/
发布于 2013-05-01 06:03:48
如果你想用星号代替用户的文本输入,你需要使用password
输入-- text
输入不能做到这一点:
<input type="password" id="txtPwd" runat="server" />
但是,默认值将为空(这也适用于text
输入)。如果您想将其初始化为默认值,您可以这样做:
<input type="password" value="dummy" id="txtPwd" runat="server" />
注意:我强烈建议而不是将用户的密码作为密码字段的默认值!它可能会泄露用户的密码。
如果您想在字段为空时将某些星号显示为占位符文本,可以使用placeholder
属性(同样,这也适用于text
输入):
<input type="password" placeholder="*****" id="txtPwd" runat="server" />
https://stackoverflow.com/questions/16309647
复制相似问题