Home > Web Front-end > JS Tutorial > body text

Introducing JS form submission information encryption

coldplay.xixi
Release: 2021-03-09 10:20:33
forward
1839 people have browsed it

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>
Copy after login

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>
Copy after login

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!

Related labels:
js
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!