希望我能得到答案...我試圖以這種格式發佈輸入值。我希望能夠獲取輸入的文字,而不是替換文字的字符。輸入類型=「密碼」不是解決方案。來自輸入的發佈數據
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