溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

用javcscript記住用戶名和密碼保存在本地儲存中,然后實現(xiàn)前端獲取

發(fā)布時間:2020-02-29 01:56:13 來源:網絡 閱讀:1083 作者:HHT15927087748 欄目:移動開發(fā)

<script type="text/javascript">

window.onload=function(){
 var Id = localStorage.getItem("txtId");

                    if(Id != null) //如果緩存中有數(shù)據,則加載出來 B5教程網
                    {
                        document.getElementById("txtId").value = Id;
                        document.getElementById("txtPwd").value = localStorage.getItem("txtPwd");
                        document.getElementById("chkRem").checked = "checked";
                    }
                    
                    }
                    //將賬號與密碼保存到Localstore
                    function remPwd() {
                        var check = document.getElementById("chkRem");
                        if(check.checked) //判斷記住密碼項是否勾選,是則記住密碼到本地緩存
                        {
                            var id = document.getElementById("txtId").value;
                            var pwd = document.getElementById("txtPwd").value;
                            localStorage.setItem("txtId", id);
                            localStorage.setItem("txtPwd", pwd);
                        } else //否則就移除本地緩存
                        {
                            localStorage.removeItem("txtId");
                            localStorage.removeItem("txtPwd");
                        }
                    }



</script>
</head>

 <body class="bg-black">

        <div class="form-box" id="login-box" >
            <div class="header">登錄頁面</div>
            <form id="formLogin" action="user_loginApp.action" class="login" method="post">
                <div class="body bg-gray">
                    <div class="form-group">
                        <input type="text" name="loginName" id="txtId" class="form-control" placeholder="請輸入用戶名"   onblur="javascript:ok_or_errorBylogin(this)"/>
                    </div>
                    <div class="form-group">
                        <input type="password" name="password" id="txtPwd"class="form-control" placeholder="請輸入密碼" onBlur="javascript:ok_or_errorBylogin(this)" />
                    </div>         
                    
                    <div class="form-group">
                        <input type="checkbox"  checked="checked" id="chkRem" name="remember_me"/> 記住密碼
                    </div>
                </div>
                <div class="footer">                                                               
                    <button type="submit" class="btn bg-olive btn-block" id="login"     
                    
                
            <hr>
             <p>
                 <b>
         XXXXXXX電子有限責任公司 </b> <br><b>XXXXXXXX有限責任公司<b> &nbsp;   &nbsp;&nbsp;&nbsp;&nbsp;     聯(lián)合開發(fā)<br /><b >&nbsp;   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;電話:0771-3304546</b><br>
                                  
            
             </p>
            
            </div></form>

</body>
</html>

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI