小兔网

介绍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 表单提交信息加密的知识。速戳>>知识兔学习精品课!