zoukankan      html  css  js  c++  java
  • 使用jQuery完成记住用户名和密码(个人记录)

    <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
    <%-- <%@taglib uri="/struts-tags" prefix="s"%> --%>
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>手机销售助理终端管理系统</title>
    <!-- <meta http-equiv="Content-Language" content="zh-cn">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> -->
    <LINK href="${pageContext.request.contextPath}/css/buttonstyle.css"
    type="text/css" rel="stylesheet">
    <LINK href="${pageContext.request.contextPath}/css/MainPage.css"
    type="text/css" rel="stylesheet">
    <!-- jquery用来记住登录名密码 -->
    <script src="${pageContext.request.contextPath}/jquery/jquery-1.11.0.js" type="text/javascript"></script>
    <script src="${pageContext.request.contextPath}/jquery/jquery.cookie.js" type="text/javascript"></script>
    <script type='text/javascript'
    src='${pageContext.request.contextPath}/script/pub.js'></script>
    <script type="text/javascript"
    src='${pageContext.request.contextPath}/script/validate.js'></script>
    <script type="text/javascript">
        
    function ini() {
    document.all.name.focus();
    }
        function checkbox()
        {
        /* alert("check box..."); */
        document.getElementById("ck_rmbUser").checked=true;
        }
      
        $(document).ready(function () {
     /*     alert("ready"); */
       
            if ($.cookie("rmbUser")=="true") {
      /*       alert($.cookie("rmbUser")); */
            $("#rmbUser").attr("checked", true);
            $("#login_name").val($.cookie("username"));
            $("#password").val($.cookie("password"));
            }
        });
        
      //记住用户名密码
        function Save() {
    /*     alert("Save()"+document.getElementById("remeberMe").checked); */
     
        if (document.getElementById("remeberMe").checked) {
      /* alert("enter"); */
                var str_username = $("#login_name").val();
                var str_password = $("#password").val();
                $.cookie("rmbUser", true, { expires: 7 }); //存储一个带7天期限的cookie
            /*     alert("fk"); */
                $.cookie("username", str_username, { expires: 7 });
                $.cookie("password", str_password, { expires: 7 });
            }
            else {
                $.cookie("rmbUser", "false", { expire: -1 });
                $.cookie("username", "", { expires: -1 });
                $.cookie("password", "", { expires: -1 });
            }
        };
        
    function check() {
    var theForm = document.forms[0];
    if (Trim(theForm.login_name.value) == "") {
    alert("请输入用户名");
    theForm.login_name.focus();
    return false;
    }
    theForm.submit();
    return true;
    }
    function checkNumberImage() {
    var imageNumber = document.getElementById("imageNumber");
    imageNumber.src = "${pageContext.request.contextPath}/image.jsp?timestamp="
    + new Date().getTime();
    }
    function checkFunction() {
    return check();
    }
    </script>
    <STYLE type=text/css>
    BODY {
    margin: 0px;
    }
    FORM {
    MARGIN: 0px;
    BACKGROUND-COLOR: #ffffff
    }
    </STYLE>
    </head>
    <body onload="ini()">
    <form action="${pageContext.request.contextPath}/system/mpsaMenuAction_menuHome.do"
    method="post" target="_top">
    <table border="0" width="100%" id="table1" height="532"
    cellspacing="0" cellpadding="0">
    <tr>
    <td></td>
    </tr>
    <tr>
    <td height="467">
    <table border="0" width="1024" id="table2" height="415"
    cellspacing="0" cellpadding="0">
    <br>
    <br>
    <br>
    <br>
    <br>
    <tr>
    <td width=12%></td>
    <td align=center
    background="${pageContext.request.contextPath}/images/index.jpg">
    <table border="0" width="98%" id="table3" height="412"
    cellspacing="0" cellpadding="0">
    <tr height=122>
    <td colspan=2></td>
    </tr>
    <tr>
    <td height="313" width="73%"></td>
    <td height="99" width="27%">
    <table border="0" width="70%" id="table4">
    <tr>
    <td width="100"><img border="0"
    src="${pageContext.request.contextPath}/images/loginname.jpg"
    width="75" height="20">
    </td>
    <td><input type="text" name="login_name" id="login_name"
    style=" 125 px" size="20" value="" maxlength="25">
    </td>
    </tr>
    <tr>
    <td width="100"><img border="0"
    src="${pageContext.request.contextPath}/images/password.jpg"
    width="75" height="20">
    </td>
    <td><input type="password" name="password" id="password"
    style=" 125 px" size="20" value="" maxlength="25">
    </td>
    </tr>
    <tr>
    <td width="100"><img border="0"
    src="${pageContext.request.contextPath}/images/check.jpg"
    width="75" height="20"></td>
    <td>
    <table>
    <tr>
    <td><input type="text" name="checkNumber"
    id="checkNumber" value="" maxlength="4" size="7">
    </td>
    <td><img
    src="${pageContext.request.contextPath}/image.jsp"
    name="imageNumber" id="imageNumber" style="cursor:hand"
    title="点击可更换图片" height="20"
    onclick="checkNumberImage()" />
    </td>
    </tr>
    </table>
    </td>
    </tr>
    <tr>
    <td width="100">
    <img border="0" src="${pageContext.request.contextPath}/images/remeber.jpg" width="75" height="20">
    </td>
    <td>
    <input type="checkbox" id="remeberMe" onclick="checkbox()"/>
    </td>
    </tr>
    <tr>
    <td width="100"></td>
    <td width="100">
    <input type="submit"
    class=btn_mouseout
    onmouseover="this.className='btn_mouseover'"
    onmouseout="this.className='btn_mouseout'" value="登   录"
    name="huifubtn" onclick="Save()">
    </td>
    </tr>
    </table></td>
    </tr>
    </table></td>
    <td width=13%></td>
    </tr>
    <tr>
    <td align="center" colspan=3>&nbsp;</td>
    </tr>
    </table></td>
    </tr>
    </table>
    </form>
    <div class="foot" align="center">版权所有:手机销售助理终端管理系统</div>
    </body>
    </html>
  • 相关阅读:
    HDU 4990 Reading comprehension(BestCoder Round #8)
    HDU 4985 Little Pony and Permutation(BestCoder Round #7)
    HDU 4983 Goffi and GCD(欧拉函数模板)
    CodeForces 590A Median Smoothing
    CodeForces 591B Rebranding
    LightOJ 1100
    Load average 负载详细解释
    Loadrunner 上传下载
    使用VisualVM远程监控JVM Linux服务器配置方法
    JVM调优(7)调优方法
  • 原文地址:https://www.cnblogs.com/seniorsa/p/3635913.html
Copyright © 2011-2022 走看看