如何在输入字段中显示文本”;密码”;键入后,再次切换到密码视图

how to show text in input field "password" and after typing on it switch again to password view

本文关键字:密码 视图 显示 字段 文本 输入      更新时间:2023-09-26

我有一些登录密码字段:

 <input type="password" name="password" id="password" value="Password" maxlength="40" required style="width: 130px; font-size: 10px;" />

作为输出,我有一个值为"password"的密码字段,它就像"********"一样显示,什么是
清晰地但我想把它看作一个文本"密码",并在键入显示********之后。怎么做??

使用placeholder属性。

<input type="password" placeholder="Password" />

jsFiddle。

这应该有效:

<input type="password" name="password" value="password" id="password"  placeholder="Password" maxlength="40" required="" style="width: 130px; font-size: 10px;">

需要注意的是,如果值属性在占位符属性之前,它将具有优先级,并且您将看到默认值集。(对于密码字段,这对我来说没有多大意义)。