前端登錄表單提交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