介绍JS 表单提交信息加密


本文摘自PHP中文网,作者coldplay.xixi,侵删。

提交表单

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

<!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加密

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

<!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 表单提交信息加密的详细内容,更多文章请关注木庄网络博客

相关阅读 >>

js数组基础知识(总结)

js中渐进增强是什么意思?

javascript如何定时自动关闭页面

js实现正则表达式验证端口范围的方法

为什么要用json

javascript操作dom对象之select(详细解答)

css3+javascript怎么做一个旋转的3d盒子?

js实现图片无缝滚动

js如何实现函数防抖与节流

如何利用js获取form表单数据

更多相关阅读请进入《js》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...