简体   繁体   English

如何通过输入屏蔽使文本字段表现得像密码字段?

[英]How I can make text field behave like password field through input masking?

I dont want to save password for my site.我不想为我的网站保存密码。 So, I tried with autocomplete = 'off', autocomplete="new-password" but it is not working.因此,我尝试使用 autocomplete = 'off', autocomplete="new-password" 但它不起作用。 Now I come up with input masking idea.现在我想出了输入屏蔽的想法。 So could you please let me know how I can change each character enter in text field to behave like password * character.那么能否请您告诉我如何更改文本字段中输入的每个字符,使其表现得像密码 * 字符。

here is an example.这是一个例子。

 .test { text-security: disc; -webkit-text-security: disc; -moz-text-security: disc; }
 <input type="text" class="test">

Just try this one but I think this will only work in Chrome.试试这个,但我认为这只适用于 Chrome。

 document.getElementById("input").oninput = ( function(event) { document.getElementById("text").innerHTML = document.getElementById("input").value; });
 #input { -webkit-text-security: disc; -moz-text-security: disc; }
 <input type="text" name="" id="input"> <p id="text"></p>

Thanks and best regards!谢谢并致以最诚挚的问候!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM