温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

用javcscript记住用户名和密码保存在本地储存中,然后实现前端获取

发布时间:2020-02-29 01:56:13 来源:网络 阅读:1083 作者:HHT15927087748 栏目:移动开发

<script type="text/javascript">

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

                    if(Id != null) //如果缓存中有数据,则加载出来 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;     联合开发<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问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI