希望我能得到答案...我试图以这种格式发布输入值。我希望能够获取输入的文字,而不是替换文字的字符。输入类型=“密码”不是解决方案。来自输入的发布数据
var text = "";
$('input[type="text"]').keyup(function(e){
\t
if(e.which === 8){
\t text = text.substr(0, text.length - 1);
}
var data = $(this).val();
$(this).val(data.replace(/[&\/\\#,+()$~%.'":*@!?^<>{}\w\s]/g, '●'));
});
$('input[type="text"]').keypress(function(e){
\t text += String.fromCharCode(e.keyCode);
console.log(text);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<input name="newname" type="text" id="txt1" autocomplete="off">
看起来这就是你想要达到的目的https://www.sitepoint.com/better-passwords-1-the-masked-password-field/ –
我会现在就试试看吧。 – Lugifah
谢谢。我如何标记为最佳答案? – Lugifah