Home  >  Article  >  Web Front-end  >  Introducing JS form submission information encryption

Introducing JS form submission information encryption

coldplay.xixi
coldplay.xixiforward
2021-03-09 10:20:331834browse

Introducing JS form submission information encryption

Submit form

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

Free learning recommendation: javascript video tutorial

Optimize form submission md5 encryption

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

If you need the md5.js file, you can privately message me. Thank you for your support!

Related free learning recommendations: javascript (video)

The above is the detailed content of Introducing JS form submission information encryption. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete