禁用屏蔽输入类型密码

时间:2015-01-14 09:24:39

标签: html types passwords masking

有没有办法禁用屏蔽?

我尝试了input[type='password'][name='TxtPassword]{ -webkit-text-security: none !important;}

但这不起作用。

提前致谢。

1 个答案:

答案 0 :(得分:0)

您可以使用JavaScript更改类型。将类型设置为text将显示文本。

document.querySelector("button").addEventListener("click", function () {
    var textbox = document.querySelector("input");
    if (textbox.type == "password") {
        textbox.type = "text";
    } else {
        textbox.type = "password";
    }
});
<input type="password" value="password" />
<button>Toggle type</button>