input输入密码变黑点密文

时间:2022-06-27 01:33:24

input输入密码加密

html代码

<form id="login-form" method="post" onsubmit="return checkForm()">
输入密码<input type="password" id="input-password">
<input type="hidden" id="md5-password" name="password">
<button type="submit">Submit</button>
</form>

js代码

function checkForm() {
var input_pwd = document.getElementById('input-password');
var md5_pwd = document.getElementById('md5-password');
// 把用户输入的明文变为MD5:
md5_pwd.value = toMD5(input_pwd.value);
// 继续下一步:
return true;
}