我有一个输入文本类型,当我开始在输入中写一些东西来设置密码格式时,我想更改格式。
这是我的html:
<div class="px-0 col-5">
<label class="px-0 col-12 mdc-text-field">
<input type="text" class="mdc-text-field__input" style="padding-left: 20px;" name="PWDDossier" id="PWDDossier" value="" />
<span class="mdc-floating-label" style="padding-left: 20px;">Mot de passe</span>
<div class="mdc-text-field__bottom-line"></div>
<i class="material-icons">
visibility
</i>
</label>
@Html.ValidationMessageFor(m => m.PWDDossier, "", new { @class = "text-danger" })
</div>
答案 0 :(得分:3)
当用户在输入中输入内容时,这将使输入类似于密码输入(但仍为文本输入)。
function make_pw(){
$("#PWDDossier").addClass("pwd");
}
.pwd{
-webkit-text-security: disc;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="px-0 col-5">
<label class="px-0 col-12 mdc-text-field">
<input type="text" class="mdc-text-field__input" style="padding-left: 20px;" name="PWDDossier" id="PWDDossier" value="" onkeydown="make_pw()" />
<span class="mdc-floating-label" style="padding-left: 20px;">Mot de passe</span>
<div class="mdc-text-field__bottom-line"></div>
<i class="material-icons">
visibility
</i>
</label>
</div>