标签:userinfo cti oca disable sed 用户信息 awesome work math
<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>尽知网</title> <link href="css/bootstrap.css" rel="stylesheet"> <link href="css/font-awesome.css" rel="stylesheet"> <link href="css/sweet-alert.css" rel="stylesheet"> <link href="css/common.css" rel="stylesheet"> <link href="css/index.css" rel="stylesheet"> <link href="css/media.css" rel="stylesheet"> <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> <!-- WARNING: Respond.js doesn‘t work if you view the page via file:// --> <!--[if lt IE 9]> <script src="https://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script> <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script> <![endif]--> </head> <body id="jz-login"> <!--header--> <nav id="jz-nav" class="navbar navbar-default"> <div class="container-fluid"> <div class="navbar-header"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="#"> <img class="img-responsive" src="images/jz-logo.png" > </a> </div> <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> <ul class="nav navbar-nav navbar-right"> <li><a class="cur" href="/尽知/index.html">首页</a></li> <li class="jz-nav-center"><a href="#">个人中心</a></li> <li><a href="#">发布</a></li> <li><a href="/尽知/login.html">登陆</a></li> <li><a href="/尽知/register.html">注册</a></li> </ul> </div> </div> </nav> <!--header end--> <!--登陆表单--> <div class="container"> <div class="jz-login"> <form class="form-signin" id="jz-form-signin" name="jz-form-signin" method="post" action=""> <input name="myusername" id="myusername" value="" type="text" class="form-control" placeholder="账户:" required> <span class="jz-name-error"></span> <input name="mypassword" id="mypassword" value="" type="password" class="form-control" placeholder="密码:" required> <div class="jz-passward"> <div class="row"> <div class="col-xs-4"> <div class="checkbox"> <label> <input type="checkbox" id="rememberMe"> 记住密码 </label> </div> </div> <div class="col-xs-4"><a href="javascript:;">忘记密码</a></div> <div class="col-xs-4"><a class="jz-register-btn pull-right" href="/尽知/register.html">注册</a></div> </div> </div> <button id="submit" class="btn btn-lg btn-primary btn-block" type="submit">登陆</button> </form> </div> </div> <!--登陆表单 end--> <div class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog"> <div class="modal-dialog modal-sm" role="document"> <div class="modal-content jz-tip-form"> </div> </div> </div> <!-- jQuery (necessary for Bootstrap‘s JavaScript plugins) --> <script src="common/jquery.js"></script> <script src="common/bootstrap.min.js"></script> <script src="common/jquery.validate.min.js"></script> <script src="common/sweet-alert.min.js"></script> <script src="common/jquery.cookie.js"></script> <script type="text/javascript"> $(function (){ /*表单验证*/ $("#submit").click(function() { /*表单验证 */ $("#jz-form-signin").validate({ rules: { myusername: { required: true }, mypassword: { required: true } }, messages: { myusername: { required: "请输入账户" }, mypassword: { required: "请输入密码" } }, submitHandler: function (form) { var $form = $(form); console.log( $form.serializeArray()); $.ajax({ type: "POST", url: ‘‘, data: $form.serializeArray(), beforeSend: function () { $form.find(‘:submit‘).prop(‘disabled‘, true); }, success: function (json) { if(json.errmsg == 1) { swal({ title: "账户和密码不对", html: false, text: "重新填写账户和密码", type: "success", showCancelButton: false, confirmButtonText: "确定", closeOnConfirm: true }); return } swal({ title: "登陆成功", html: false, text: "登陆成功", type: "success", showCancelButton: false, confirmButtonText: "确定", closeOnConfirm: true }, function(inputValue){ // window.location.href = ""; //?"+Math.random(); /*setTimeout(function() { swal(‘Ajax request finished!‘); }, 2000);*/ }); }, complete: function () { $form.find(‘:submit‘).prop(‘disabled‘, false); } }); } }); }); /*记住密码*/ if ($.cookie("rmbUser") == "true") { $("#rmbUser").attr("checked", true); $("#user").val($.cookie("userName")); $("#pass").val($.cookie("passWord")); } saveUserInfo(); //保存用户信息 function saveUserInfo() { var rmbUser = $("#rememberMe"); var userName = $("#myusername").val(); var passWord = $("#mypassword").val(); if (rmbUser.attr("checked") == true) { $.cookie("rmbUser", "true", { expires: 7 }); // 存储一个带7天期限的 cookie $.cookie("userName", userName, { expires: 7 }); // 存储一个带7天期限的 cookie $.cookie("passWord", passWord, { expires: 7 }); // 存储一个带7天期限的 cookie } else { $.cookie("rmbUser", "false", { expires: -1 }); $.cookie("userName", ‘‘, { expires: -1 }); $.cookie("passWord", ‘‘, { expires: -1 }); } } }); </script> </body> </html>
标签:userinfo cti oca disable sed 用户信息 awesome work math
原文地址:http://www.cnblogs.com/wei-dong/p/7069541.html