• cookie记住密码


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <%@page language="java" import="java.util.*" pageEncoding="UTF-8"%>
    <%@ include file="/commons/taglib.jsp"%>
    <%@taglib uri="http://java.fckeditor.net" prefix="FCK" %>
    <%@ taglib prefix="jqui" uri="/joyoou_jqueryeasyui_tags" %>
    <%@ taglib prefix="s" uri="/struts-tags" %>
    <head>
        <title></title>
        <jqui:include />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /> 
    <link href="http://www.cnblogs.com/css/member/mcss/main.css" rel="stylesheet" type="text/css" />
    <link href="http://www.cnblogs.com/css/member/css/index.css" rel="stylesheet" type="text/css" />
    </head>
    <script type="text/javascript">
        var flag = 0;
    $(function() {
        var loginError = "${loginError}";
        if(loginError!=""&&loginError!=null) {
            alert(loginError);
        }
        Cookies.init();
        getCookie();
    });

    function checkLoginForm() {
        var userName = $('#username').val();
        var passw = $('#userpassword').val();
        var codeVal = $('#randcode').val();
        if(userName.trim()==''||userName.trim()==null) {
            alert("请输入你的用户名!");
            $('#username').focus();
            return false;
        }
        else if(passw==''&&passw=='') {
            alert("请输入登录密码!");
            $('#userpassword').focus();
            return false;
        }
        else if(passw.length<6) {
            alert("请输入正确的登录密码!");
            $('#userpassword').focus();
            return false;
        }
        else if(codeVal==null||codeVal=="") {
            $('#randcode').focus();
            alert("请填写验证码!");
            return false;
        }
    //    else if($('#codeFont').val()!=null) {
        else if(flag==1) {
            changeRandCode();
            $('#randcode').focus();
            alert("请填写正确的验证码!");
            return false;
        }
        return true;
    }

    function changeRandCode() {
        $('#imgRandCode').attr("src", "http://www.cnblogs.com/jsp/randcode.jsp?randCode=<%=new java.util.Date().getTime()%>&t="+new Date());
    }

    function checkCode() {
        flag = 0;
        var codeVal = $('#randcode').val();
        $('#codeFont').remove();
    /*    if (codeVal.length == 0) {
    //        $('#cap_resend').after("<font color='red' id='codeFont'>*请填写验证码!</font> ");
            flag = 0;
        }*/
         if (codeVal.length == 4) {
            $.getJSON("checkcode.do?randcode = " + codeVal + "&t=" + new Date(), function(data) {
                if (data.errorinfo != "" && data.errorinfo != null) {
                    flag = 1;
    //                $('#codeFont').remove();
    //                $('#cap_resend').after("<font color='red' id='codeFont'>*"+data.errorinfo+"</font> ");
                }
            });
        }
        else {
             flag = 1;
    //         $('#codeFont').remove();
    //        $('#cap_resend').after("<font color='red' id='codeFont'>*请填写正确的验证码!</font> ");
        }
    }

    function regist() {
        storeCookie();
    }
     
    function storeCookie() {
        var userName = $('#username').val();
        var password = $('#userpassword').val();
        if($('#isCookie').attr('checked')==true) {
            if(userName!= '') {
                Cookies.create('51743n', userName,7);
            }
            if(password!= '') {
                Cookies.create('51743p', password,7);
            }
        }
    }
    function getCookie() {
        var userName = $('#username').val();
        var password = $('#userpassword').val();
     $('#username').attr("value",Cookies['51743n']);
     $('#userpassword').attr("value",Cookies['51743p']);
    }
    var Cookies = {
     init: function () {
      var allCookies = document.cookie.split('; ');
      for (var i=0;i<allCookies.length;i++) {
       var cookiePair = allCookies[i].split('=');
       this[cookiePair[0]] = unescape(cookiePair[1]);
      }
     },
     create: function (name,value,days) {
      if (days) {
       var date = new Date();
       date.setTime(date.getTime()+(days*24*60*60*1000));
       var expires = "; expires="+date.toGMTString();
      }
      else var expires = "";
      document.cookie = name+"="+escape(value)+expires+"; path=/";
      this[name] = escape(value);
     },
     erase: function (name) {
      this.create(name,'',-1);
      this[name] = undefined;
     }
    };
    </script>
    <body>
    <%--<a target="_blank" style="clear:both;display: scroll; position: fixed; top: 12px; left: 300px; 100px; height: 55px;" href="http://www.cnblogs.com/news/index/list.do"></a>--%>

    <tour:memberTop login="false" />
    <div class="area">
     <div class="login">
            <form id="loginForm" action="loginon.do" method="post" onsubmit="return checkLoginForm();">
         <ul>
             <li style="font-size:16px; font-weight:bold; border-bottom:#cccccc 1px solid; height:40px; margin-bottom:15px;">用户登陆</li>
                <li style="height:50px;">如果您在社区已经拥有帐号,请使用该帐号直接登陆。不需重复注册。</li>
                <li>用户名:
                  <label>
                    <input type="text" id="username" tabindex="1" name="member.userName" class="borderline">
                  </label>
                </li>
                <li>密 码:
                  <label>
                    <input type="password" tabindex="2" id="userpassword" name="member.password" class="borderline">
                  </label>
                </li>
              <li>验证码:
                <label>
                    <input name="textfield" tabindex="3" maxlength="4" type="text" id="randcode" size="8" class="borderline" onkeyup="checkCode()">
                </label>
                <label id="rand">
                        <img id='imgRandCode' width='64' height='20' onclick="changeRandCode()" src='http://www.cnblogs.com/jsp/randcode.jsp?rand=<%=new java.util.Date().getTime()%>' valign='top'>
                       <a href='javascript:changeRandCode()' tabindex="4" id='cap_resend'>看不清,换一张</a>
                </label>
                </li>
                <li style="padding-left:50px;">
                    <label>
                      <input type="checkbox" tabindex="5" onclick="regist()" name="复选框组1" value="复选框" id="isCookie"> 记住密码
                    </label>
                </li>
      <li style="padding-left:50px;">
                <input type="submit" value="" tabindex="6" class="botton" style="height:27px;75px;background:url('http://images.cnblogs.com/user/dlanniu.gif') repeat scroll -8px -3px;cursor:pointer;">
            </li>
              <li style="font-size:16px; font-weight:bold; border-bottom:#cccccc 1px solid; height:40px; margin-bottom:15px; margin-top:30px;">还没注册吗?</li>
              <li style="height:50px;">

                <input name="" onclick="window.location = 'registjsp.do';" type="button" value=" 立即注册 " style="height:25px;"></li>
         </ul>
        </form>
      </div>
    </div>
    <div class="w_940">
      <iframe frameborder=0 width=940 height=150 scrolling=no src="http://www.cnblogs.com/copy/index.html"> </iframe>
    </div>
    </body>
    </html>

  • 相关阅读:
    圆的国度:Can you understand what you see?
    P5732 杨辉三角
    Django中与CSRF相关的内容
    Python中一些可能会问到的面试题
    python协程,线程的其他方法
    python 线程
    python-进程-其他方法(2)
    python 进程的一些其他方法
    python进程--传参,for循环创建,join方法
    python并发编程
  • 原文地址:https://www.cnblogs.com/Earl/p/2073973.html
Copyright © 2020-2023  润新知