首頁  >  文章  >  web前端  >  介紹JS 表單提交資訊加密

介紹JS 表單提交資訊加密

coldplay.xixi
coldplay.xixi轉載
2021-03-09 10:20:331780瀏覽

介紹JS 表單提交資訊加密

提交表單

<!DOCTYPE html><html lang="en"><head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="md5.js"></script></head><body><form action="#" method="post" >
    <p>
        <span>用户名:</span> <input type="text" id="username" name="username">
    </p>
    <p>
        <span>密码:</span> <input type="password" id="pwd" name="pwd">
    </p><!--      绑定时间 onclick被点击-->
    <button type="submit" onclick="aaa()" >提交</button></form><script>
    function  aaa(){
       var usern=document.getElementById("username");
       var pwd=document.getElementById("pwd");

         console.log(usern)
         console.log(pwd)

       pwd.value=md5(pwd.value);
         console.log(pwd.value);

       
    }</script></body></html>

#免費學習推薦:javascript影片教學

優化表單提交md5加密

<!DOCTYPE html><html lang="en"><head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="md5.js"></script></head><body><!--  onsubmit 绑定一个提交检测函数  true false 将这个结果返回表单 ,使用 onsubmit 接收 onsubmit="return aaa() --><form action="https://home.firefoxchina.cn/" method="post"  onsubmit="return aaa()">
    <p>
        <span>用户名:</span> <input type="text" id="username" name="username">
    </p>
    <p>
        <span>密码:</span> <input type="password" id="pwd" name="pwd">
    </p>

    <input type="hidden" id="md5-password" name="password"><!--      绑定时间 onclick被点击-->
    <button type="submit" >提交</button></form><script>
    function  aaa(){
       var usern=document.getElementById("username");
       var pwd=document.getElementById("pwd");
       var md5=document.getElementById("md5-password")


        md5.value=md5(pwd.value);

        // console.log(usern)
        // console.log(pwd)

        //pwd.value=md5(pwd.value);
        // console.log(pwd.value);

        //可以校验判断表单内容  true 就是通过提交  false 就是组织提交
        return true;
    }</script></body></html>

如果需要md5.js那個檔案可以私聊我,感謝大家的支持!

相關免費學習推薦:javascript(影片)

#

以上是介紹JS 表單提交資訊加密的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:csdn.net。如有侵權,請聯絡admin@php.cn刪除