_015_JS_js form表单的正确提交方式(关于password加密传输)

来自https://blog.csdn.net/cominglately/article/details/78133033

安全考虑表单提交的时候不输入明文口令 ,采用md5加密。

下面的例子,为了input password 表单没有name, (没有name的表单不会提交) 这样避免密码由用户输入的密码,变成32位"*", 给客户看到

<form action="" method="post" class="form-inline" id="from-test" onsubmit="return checkInput()">
    <input type="text" id="username" name="username"> 姓名 <br>
    <input type="password" id="password"> 密码 <br>
    <input type="hidden" id="password_md5" name="password">
    <button type="submit">Submit</button>
</form>
function checkInput() {
    var password_input = document.getElementById('password');
    var password_md5 = document.getElementById('password_md5');

    // set password
    password_md5.value =  md5(password_input.value);
    return true;
}

猜你喜欢

转载自blog.csdn.net/poiuyppp/article/details/81355637