前端登录表单提交MD5加密


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <!--MD5工具类-->
    <script src="https://cdn.bootcdn.net/ajax/libs/blueimp-md5/2.16.0/js/md5.min.js"></script>
</head>
<body>
<!--
表单绑定提交事件
onsubmit=绑定一个提交检测的函数,true,false
将这个结果返回给表单,使用onsubmit接收
-->
<form action="https://www.baidu.com/" method="post" onclick="return aaa()">
    <p>
        <span>用户名:</span>
        <input type="text" id="username" name="username">
    </p>

    <p>
        <span>密码:</span>
        <input type="password" id="input-password">
    </p>

    <input type="hidden" id="md5-password" name="password">

    <!--绑定事件onclick被点击-->
    <button type="submit">提交</button>
</form>

<script>
    function aaa() {
        alert(1);
        var uname=document.getElementById('username');
        var pwd=document.getElementById('input-password');
        var md5pwd=document.getElementById('md5-password');
        // pwd.value=md5(pwd.value);
        md5pwd.value=md5(pwd.value);
        //可以检验判断表单内容,true就是通过提交,false阻止提交
        return false;
    }
</script>
</body>
</html>

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM