Javascript登錄頁面“記住密碼”實現


  JS記住密碼實現效果:

 JavaScript Code 
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
31
32
 
<!DOCTYPE html>
<html>
    <head>
        <title>用戶名密碼</title>
        <script type= "text/javascript"  src= "http://ajax.microsoft.com/ajax/jquery/jquery-1.4.min.js" ></script>
        <script>
            
function  SavePassword()
            {
                
if (document.getElementById( "savePassword" ).checked)
                {
                    
var  username = $( "#username" ).val();
                    
var  password = $( "#password" ).val();
                    window.sessionStorage.username =  username;
                    window.sessionStorage.password = password;
                    localStorage.rmbPassword = 
true ;
                }
                
else
                {
                    localStorage.rmbPassword = 
false ;
                }
            }
        </script>
    </head>
    <body>
        <label id=
"login"   for = "username"  style= "margin:auto;font-size:15px" >用戶名:</label>
        <input style=
"margin:auto;font-size:15px"  type= "text"  name= "username"  id= "username"   placeholder= "輸入用戶名..."  >
        <br><br>
        <label id=
"login"   for = "password"  style= "margin:auto;font-size:15px" >密&nbsp&nbsp&nbsp碼:</label>
        <input style=
"margin:auto;font-size:15px"  type= "password"  name= "password"  id= "password"  placeholder= "輸入密碼..." >
        <input type=
"checkbox"  name= "savePassword"  id= "savePassword"  checked= "checked"  onclick= "SavePassword()" >
    </body>
</html>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM