测试源码

代码结构:

package com.bie.dao;
//20173522 李秦
import com.bie.po.User;

/**
* @author BieHongLi
* @version zx
* 创建一个接口用于声明用户登陆注册的方法
*/
public interface UserDao {

    /***
     * 用户登陆的方法声明
     * @param user
     * @return
     */
    public User login(User user);

    /***
     * 用户注册的方法声明
     * @param user
     * @return
     */
    public boolean register(User user);
}

package com.bie.dao.impl;


import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;


import com.bie.dao.UserDao;
import com.bie.po.User;
import com.bie.utils.BaseDao;


/**
* @author BieHongLi
* @version
*
*/
public class UserDaoImpl implements UserDao{


@Override
public User login(User user) {
Connection con=null;
PreparedStatement ps=null;
ResultSet rs=null;
try {
con=BaseDao.getCon();//1:获取数据库的连接
//2:书写sql语句
String sql="select * from user where name=? and password=? ";
ps=con.prepareStatement(sql);//3:预编译
//4:设置值
ps.setString(1, user.getName());
ps.setString(2, user.getPassword());
rs=ps.executeQuery();//5:执行sql语句
User users=null;
if(rs.next()){
users=new User();
//从数据库中获取值设置到实体类的setter方法中
users.setId(rs.getInt("id"));
users.setName(rs.getString("name"));
users.setPassword(rs.getString("password"));
users.setEmail(rs.getString("email"));
users.setPhone(rs.getString("phone"));

return user;
}else{
return null;
}

} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}


/***
* 插入的方法,即注册
*/
@Override
public boolean register(User user) {
String sql="insert into user values(0,?,?,?,?) ";
List<Object> list=new ArrayList<Object>();
list.add(user.getName());
list.add(user.getPassword());
list.add(user.getEmail());
list.add(user.getPhone());

boolean flag=BaseDao.addUpdateDelete(sql,list.toArray());
if(flag){
return true;
}else{
return false;
}
}


}

package com.bie.po;
/**
* @author BieHongLi
* @version
*/
public class User
{

private Integer id;
private String name;
private String password;
private String email;
private String phone;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}

//重写toString 方法
@Override
public String toString() {
return "User [id=" + id + ", name=" + name + ", password=" + password + ", email=" + email + ", phone=" + phone
+ "]";
}

}

package com.bie.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.bie.dao.UserDao;
import com.bie.dao.impl.UserDaoImpl;
import com.bie.po.User;

/**
* @author BieHongLi
* @version
*
*/
@WebServlet("/user/userlogin")
public class UserLoginServlet extends HttpServlet{

private static final long serialVersionUID = 1L;

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
this.doPost(request, response);
}

@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
User user=new User();
//获取login.jsp页面提交的账号和密码
String name=request.getParameter("name");
String password=request.getParameter("password");
//测试数据
System.out.println(name+" "+password);
//获取login.jsp页面提交的账号和密码设置到实体类User中
user.setName(name);
user.setPassword(password);

//引入数据交互层
UserDao dao=new UserDaoImpl();
User us=dao.login(user);
//测试返回的值
System.out.println(us);
if(us!=null){
request.setAttribute("info", "登陆成功");
}else{
request.setAttribute("info", "登录失败");
}

request.getRequestDispatcher("/index/info.jsp").forward(request, response);
}

}

package com.bie.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.bie.dao.UserDao;
import com.bie.dao.impl.UserDaoImpl;
import com.bie.po.User;

/**
* @author BieHongLi
* @version 创建时间:2017年2月21日 下午1:34:17
* 注册的servlet
*/
@WebServlet("/user/userregister")
public class UserRegisterServlet extends HttpServlet{

private static final long serialVersionUID = 1L;

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
this.doPost(request, response);
}

@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
User user=new User();
//获取login.jsp页面提交的账号和密码
String name=request.getParameter("name");
String password=request.getParameter("password");
String email=request.getParameter("email");
String phone=request.getParameter("phone");

//获取register.jsp页面提交的账号和密码设置到实体类User中
user.setName(name);
user.setPassword(password);
user.setEmail(email);
user.setPhone(phone);

//引入数据交互层
UserDao dao=new UserDaoImpl();
boolean flag=dao.register(user);
if(flag){
request.setAttribute("info", "注册成功");
}else{
request.setAttribute("info", "注册失败");
}

request.getRequestDispatcher("/index/info.jsp").forward(request, response);
}

}

package com.bie.utils;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ResourceBundle;

/**
* @author BieHongLi
* @version
* 数据交互层dao层
*/
public class BaseDao
{
private static String dbUrl="jdbc:mysql://localhost:3306/test";
private static String dbUserName="root";
private static String dbPassword="1108.shjzh..sql.lq";
private static String jdbcName="com.mysql.jdbc.Driver";
/* 获取数据库的连接*/
public static Connection getCon()
{
Connection con = null;
try {
Class.forName(jdbcName);
try {
con = DriverManager.getConnection(dbUrl, dbUserName, dbPassword);
} catch (SQLException e) {
e.printStackTrace();
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
System.out.println("已获得数据库的连接");
return con;
}
/* 关闭数据库连接*/
public static void close(Connection conn,PreparedStatement ps,ResultSet rs)
{
if(rs!=null){//关闭资源,避免出现异常
try {
rs.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if(ps!=null){
try {
ps.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if(conn!=null)
{
try
{
conn.close();
conn=null;
} catch (SQLException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

/***
* 同意增删改的方法
* @param sql
* @param arr
* @return
*/
public static boolean addUpdateDelete(String sql,Object[] arr){
Connection conn=null;
PreparedStatement ps=null;
try {
conn=BaseDao.getCon();//第一步 :连接数据库的操作
ps=conn.prepareStatement(sql);//第二步:预编译
//第三步:设置值
if(arr!=null && arr.length!=0){
for(int i=0;i<arr.length;i++){
ps.setObject(i+1, arr[i]);
}
}
int count=ps.executeUpdate();//第四步:执行sql语句
if(count>0){
return true;
}else{
return false;
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return false;
}

/* public static void main(String[] args)
{
BaseDao.getCon();
System.out.println("测试数据库链接成功");
}*/

}

package com.bie.utils;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;

/**
* @author BieHongLi
* @version 创建时间:2017年2月21日 上午11:08:49
*
*/
@WebFilter("/*")
public class UTFFilter implements Filter{

@Override
public void destroy() {
// TODO Auto-generated method stub

}

@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse,
FilterChain filterChain)throws IOException, ServletException {
//将servletRequest转发为HttpServletRequest
HttpServletRequest request=(HttpServletRequest)servletRequest;
request.setCharacterEncoding("utf-8");
filterChain.doFilter(servletRequest, servletResponse);
}

@Override
public void init(FilterConfig arg0) throws ServletException {
// TODO Auto-generated method stub

}

}

login.jsp:

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>用户登陆页面</title>
<style type="text/css">
h1{text-align:left;}
h4{text-align:left;color:red;}
body{background:url(images/1.png)}
a{text-decoration:none;font-size:20px;color:black;}
a:hover{text-decoration:underline;font-size:24px;color:red;}
</style>

</head>
<body>
<form action="user/userlogin" method="post">
    <h1>河北省重大技术需求征集系统</h1>
    <h4>装饰中......</h4>
    <hr/>
    <table align="left">
        <tr>
            <td>账号:</td>
            <td><input type="text" name="name" id="name"></td>
        </tr>
        <tr>
            <td>密码:</td>
            <td><input type="password" name="password" id="password"></td>
        </tr>
        <tr>
            <td colspan="1">
            </td>
            <td>
                <input type="submit" value="登陆"/>
                <input type="reset" value="重置"/>
                <a href="register.jsp" target="_blank">注册</a>
            </td>
        </tr>
    </table>
</form>
</body>
</html>

main.jsp:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>河北省重大技术需求征集问卷调查系统</title>
        <!--框架必需start-->
        <link href="css/import_basic.css" rel="stylesheet" type="text/css"/>
        <link href="skins/sky/import_skin.css" rel="stylesheet" type="text/css" id="skin" themeColor="blue"/>
        <script type="text/javascript" src="js/jquery-1.4.js">
        </script>
        <script type="text/javascript" src="js/bsFormat.js">
        </script>
        <!--框架必需end--><!--引入弹窗组件start-->
        <script type="text/javascript" src="js/attention/zDialog/zDrag.js">
        </script>
        <script type="text/javascript" src="js/attention/zDialog/zDialog.js">
        </script>
        <!--引入弹窗组件end--><!--修正IE6支持透明png图片start-->
        <script type="text/javascript" src="js/method/pngFix/supersleight.js">
        </script>
        <!--修正IE6支持透明png图片end-->
        <script>
            function bookmarksite(title, url){
                if (window.sidebar) // firefox
                    window.sidebar.addPanel(title, url, "");
                else
                    if (window.opera && window.print) { // opera
                        var elem = document.createElement(‘a‘);
                        elem.setAttribute(‘href‘, url);
                        elem.setAttribute(‘title‘, title);
                        elem.setAttribute(‘rel‘, ‘sidebar‘);
                        elem.click();
                    }
                    else
                        if (document.all)// ie
                            window.external.AddFavorite(url, title);
            }
        </script>
    </head>
    <body>
        <div id="mainFrame">
            <!--头部与导航start-->
            <div id="hbox">
                <div id="bs_bannercenter">
                    <div id="bs_bannerleft">
                        <div id="bs_bannerright">
                            <div class="bs_banner_logo">
                            </div>
                            <div class="bs_banner_title">
                            </div>
                            <div class="bs_nav">
                                <div class="bs_navleft">
                                    <li>
                                        <span id="username">
                                        </span>您好!今天是
                                        <script>
                                            var weekDayLabels = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六");
                                            var now = new Date();
                                            var year = now.getFullYear();
                                            var month = now.getMonth() + 1;
                                            var day = now.getDate()
                                            var currentime = year + "年" + month + "月" + day + "日 " + weekDayLabels[now.getDay()]
                                            document.write(currentime)
                                        </script>
                                    </li>
                                    <div class="clear">
                                    </div>
                                </div>
                                <div class="bs_navright">
                                    <span class="icon_no hand" onclick=‘top.Dialog.confirm("确定要退出系统吗",function(){window.location="exitServlet"});‘>退出系统</span>
                                    <div class="clear">
                                    </div>
                                </div>
                                <div class="clear">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!--头部与导航end-->
            <table width="100%" cellpadding="0" cellspacing="0" class="table_border0">
                <tr>
                    <!--左侧区域start-->
                    <td id="hideCon" class="ver01 ali01">
                        <div id="lbox">
                            <div id="lbox_topcenter">
                                <div id="lbox_topleft">
                                    <div id="lbox_topright">
                                        <div class="lbox_title">
                                            操作菜单
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div id="lbox_middlecenter">
                                <div id="lbox_middleleft">
                                    <div id="lbox_middleright">
                                        <div id="bs_left">
                                            <IFRAME scrolling="no" width="100%" frameBorder=0 id=frmleft name=frmleft src="leftPages/accordition.html" allowTransparency="true">
                                            </IFRAME>
                                        </div>
                                        <!--更改左侧栏的宽度需要修改id="bs_left"的样式-->
                                    </div>
                                </div>
                            </div>
                            <div id="lbox_bottomcenter">
                                <div id="lbox_bottomleft">
                                    <div id="lbox_bottomright">
                                        <div class="lbox_foot">
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </td>
                    <!--左侧区域end-->
                    <!--中间栏区域start-->
                    <td class="main_shutiao">
                        <div class="bs_leftArr" id="bs_center" title="收缩面板">
                        </div>
                    </td>
                    <!--中间栏区域end-->
                    <!--右侧区域start-->
                    <td class="ali01 ver01" width="100%">
                        <div id="rbox">
                            <div id="rbox_topcenter">
                                <div id="rbox_topleft">
                                    <div id="rbox_topright">
                                        <div class="rbox_title">
                                            操作内容
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div id="rbox_middlecenter">
                                <div id="rbox_middleleft">
                                    <div id="rbox_middleright">
                                        <div id="bs_right">
                                            <IFRAME scrolling="no" width="100%" frameBorder=0 id=frmright name=frmright src="templete/open.html" allowTransparency="true">
                                            </IFRAME>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div id="rbox_bottomcenter">
                                <div id="rbox_bottomleft">
                                    <div id="rbox_bottomright">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </td>
                    <!--右侧区域end-->
                </tr>
            </table>
            <!--尾部区域start-->
            <div id="fbox">
                <div id="bs_footcenter">
                    <div id="bs_footleft">
                        <div id="bs_footright">
                            业务咨询电话:0311-85813216     技术服务电话:13028644840 18330107787
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!--尾部区域end-->
        <!--浏览器resize事件修正start-->
        <div id="resizeFix">
        </div>
        <!--浏览器resize事件修正end-->
        <!--载进度条start-->
        <div class="progressBg" id="progress" style="display:none;">
            <div class="progressBar">
            </div>
        </div>
        <!--载进度条end-->
    </body>
    <script>

        $(document).ready(function(){
            GetRequest();

        });
        function GetRequest(){
          doAjax("userShowServlet", null, function(rstText) {
                var result=eval(‘(‘+rstText+‘)‘);
                if(result.status==‘OK‘)
                    {
                    var s=result.user;
                    $("#username").html(s);
                    }else{
                        window.location.href="login.html";
                        }
            });
            }

function getXMLHttpResquest() {
      var request;
      if (window.XMLHttpRequest)
      {
          request = new XMLHttpRequest();
      }
      else
      {
          try
          {
              request = new ActiveXObject("Microsoft.XMLHTTP");
          }
          catch (e)
          {
              request = new ActiveXObject("Msxml2.XMLHTTP");
          }
      }
      return request;
}
function doAjax(url,params,callBack) {
    var req=getXMLHttpResquest();
    if(req!=null)
        {
        req.onreadystatechange=function(){
            if(req.readyState==4)
                {
                if(200==req.status)
                    {
                    callBack(req.responseText);

                    }else if(404==req.status)
                        {
                        //alert(‘404-HTTP请求路径错误!‘);
                        window.location.href="login.html";
                        }
                    else if(500==req.status)
                        {
                        alert(‘500-HTTP请求路径错误!‘);
                        window.location.href="login.html";
                        }

                }

        };
        req.open("POST",url,true);
        req.setRequestHeader("Content-Type","application/x-www-form-urlencoded;;charset=utf-8");
        req.send(params);
    }

}

    </script>
</html>

register.jsp:

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>注册的页面</title>
<style type="text/css">
h1{text-align:center;}
h4{text-align:right;color:red;}
body{background:url(images/2.png)}
</style>

<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
        //alert("测试jQuery是否能用");
        $("#form1").submit(function(){
            var name=$("#name").val();//获取提交的值
            if(name.length==0){//进行判断,如果获取的值为0那么提示账号不能为空
                //alert("aa");//测试使用
                $("#nameError").html("账号不能为空");
                return false;
            }

            //密码进行验证不能为空
            var password=$("#password").val();//获取提交的密码的值
            if(password.length==0){
                $("#passwordError").html("密码不能为空");
                return false;
            }

            //确认密码进行验证
            var relpassword=$("#relpassword").val();//获取提交的确认密码的值
            if(relpassword.length==0){
                $("#relpasswordError").html("确认密码不能为空哦");
                return false;
            }

            if(password!=relpassword){
                $("#relpasswordError").html("确认密码输入不正确,请重新输入");
                return false;
            }
        });

    });
</script>
</head>
<body>
<form action="user/userregister" method="post" id="form1">
    <h1>用户注册页面</h1>
    <h4>装饰中......</h4>
    <hr/>
    <table align="center">
        <tr>
            <td>账&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;号:</td>
            <td>
                <input type="text" name="name" id="name"/>
                <div id="nameError" style="display:inline;color:red;"></div>
            </td>
        </tr>
        <tr>
            <td>密&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;码:</td>
            <td>
                <input type="password" name="password" id="password">
                <div id="passwordError" style="display:inline;color:red;"></div>
            </td>
        </tr>
        <tr>
            <td>确认密码:</td>
            <td>
                <input type="password" name="relpassword" id="relpassword">
                <div id="relpasswordError" style="display:inline;color:red;"></div>
            </td>
        </tr>
        <tr>
            <td>电话号码:</td>
            <td><input type="text" name="phone" id="phone"></td>
        </tr>
        <tr>
            <td>电子邮件:</td>
            <td><input type="text" name="email" id="email"></td>
        </tr>
        <tr>
            <td colspan="1">
            </td>
            <td>
                <input type="submit" value="注册"/>
                <input type="reset" value="重置"/>
                <a href="login.jsp" target="_blank">登陆</a>
            </td>
        </tr>
    </table>
</form>
</body>
</html>

xiugai.jsp:

<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>显示文本框的值</title>
   <script type="text/javascript" language="javascript">
   //旧密码调用鼠标跟随效果
   function old_pass(status,ev,id,label){
     var lab=document.getElementById(label).innerText;
     if(lab==1){
        old_pass_confirm(status,ev,id)
     }
   }

   //旧密码验证跟随效果
   function old_pass_confirm(status,ev,id){
       var value=document.getElementById(id).value;
       var object=document.getElementById(id);
       var var_length=value.length;
       if(var_length==0){
         var lab9=‘请填写值‘;
         document.getElementById(‘lable1‘).innerText=lab9;
         fu(status,ev);
         object.setAttribute("className","input");
       }else{
         var show = document.getElementById(‘showlianxi‘);
         show.style.display=‘none‘;
         object.setAttribute("className","");
       }
   }
   //密码框调用鼠标跟随效果
    function showlianxi(status,ev,id,label){
            var lab=document.getElementById(label).innerText;
                 if(lab==1){
                   yanzheng(status,ev,id);
                 }
        } 

      <!--当密码不符合要求时,显示鼠标跟随效果-->
    function yanzheng(status,ev,id){
       var value=document.getElementById(id).value;
       var object=document.getElementById(id);
       var var_length=value.length;
       var reg_small=new RegExp("^[a-z][a-z]*$");
       var reg_big=new RegExp("^[A-Z][A-Z]*$");
       var reg_num=new RegExp("^[0-9][0-9]*$");
       if(var_length==0){
                 var lab1=‘请填写值‘;
                 document.getElementById(‘lable1‘).innerText=lab1;
                 fu(status,ev);
                 object.setAttribute("className","input");
            }else if(var_length<6&&var_length>0){
                 var lab2=‘最小长度为6,当前长度为‘+var_length+‘.‘;
                 document.getElementById(‘lable1‘).innerText=lab2;
                 fu(status,ev);
                 object.setAttribute("className","input");
            } else if(var_length>20){
                  var lab3=‘最大长度为20,当前长度为‘+var_length;
                document.getElementById(‘lable1‘).innerText=lab3;
                fu(status,ev);
                object.setAttribute("className","input");
            }else if(value.match(reg_small)||value.match(reg_big)){
                var lab4=‘密码不能只包含小写或大写字母‘;
                document.getElementById(‘lable1‘).innerText=lab4;
                fu(status,ev);
                object.setAttribute("className","input");
            }else if(value.match(reg_num)){
                var lab5=‘密码不能只包含数字‘;
                document.getElementById(‘lable1‘).innerText=lab5;
                fu(status,ev);
                object.setAttribute("className","input");
            }
            else{
            var show = document.getElementById(‘showlianxi‘);
            show.style.display=‘none‘;
            object.setAttribute("className","");
            }

    }

    //确认密码调用鼠标跟随效果
    function showdiv(status,ev,id,conf_id,label){
       var lab=document.getElementById(label).innerText;
           if(lab==1){
             confirm_pass(status,ev,id,conf_id);
           }
    }    

    //验证再次输入的密码效果
    function confirm_pass(status,ev,id,conf_id){
       var value1=document.getElementById(id).value;
       var value2=document.getElementById(conf_id).value;
       var object=document.getElementById(conf_id);
       var var_length=value2.length;
       if(var_length==0){
          var lab6=‘请填写值‘;
          document.getElementById(‘lable1‘).innerText=lab6;
          fu(status,ev);
          object.setAttribute("className","input");
        }else if(value1!=value2){
          var lab7=‘两次填写不一致,请重新填写‘;
          document.getElementById(‘lable1‘).innerText=lab7;
          fu(status,ev);
          object.setAttribute("className","input");
        }else{
           var show = document.getElementById(‘showlianxi‘);
            show.style.display=‘none‘;
           object.setAttribute("className","");
        }
    }

    //鼠标跟随效果
     function fu(status,ev){
               var  e= ev||window.event;
            var show = document.getElementById(‘showlianxi‘);
            var obj=e.target||e.srcElement;
         switch(status){
                case ‘over‘:
                    show.style.position=‘absolute‘;
                    if(e.pageX){
                        show.style.left=e.pageX+20+‘px‘;
                        show.style.top=e.pageY+‘px‘;
                        }
                    else{
                        show.style.left=e.clientX + document.body.scrollLeft+ document.documentElement.scrollLeft+5;
                        show.style.top=e.clientY + document.body.scrollTop+ document.documentElement.scrollTop+5;
                        }
                    show.style.display=‘block‘;
                    break;
                case ‘out‘:
                show.style.display=‘none‘;
                break;
               }
     }
     //旧密码的onblur事件调用此方法。
     function old_psss_onblur(test,label){
       var value= document.getElementById(test).value;
       var object= document.getElementById(test);
       var var_length=value.length;
       document.getElementById(label).innerText=1;
       if(var_length==0){
          object.setAttribute("className","input");
          return false;
      }else{
        object.setAttribute("className","");
        return true;
      }
    }

     //密码的onblur事件调用此方法。
     function func(test,label){
          var reg_small=new RegExp("^[a-z][a-z]*$");
          var reg_big=new RegExp("^[A-Z][A-Z]*$");
          var reg_num=new RegExp("^[0-9][0-9]*$");
          var value= document.getElementById(test).value;
          var object= document.getElementById(test);
          var var_length=value.length;
          document.getElementById(label).innerText=1;
          if(value==null||value==‘‘){
            object.setAttribute("className","input");
            return false;
          }else if(var_length<6&&var_length>0){
            object.setAttribute("className","input");
            return false;
          }else if(var_length>20){
            object.setAttribute("className","input");
            return false;
          }else if(value.match(reg_small)||value.match(reg_big)){
            object.setAttribute("className","input");
            return false;
          }else if(value.match(reg_num)){
            object.setAttribute("className","input");
            return false;
          }else{
           object.setAttribute("className","");
           return true;
          }
        }  

    //确认密码的onblur事件调用此方法
    function new_password_confirm(new_password,new_password_confirmation,label){
           var new_passvalue=document.getElementById(new_password).value;
           var new_pass_confirmvalue=document.getElementById(new_password_confirmation).value;
           var new_pass_confirm_obj=document.getElementById(new_password_confirmation);
           document.getElementById(label).innerText=1;
           if(new_pass_value.length==0){
               new_pass_confirm_obj.setAttribute("className","input");
               return false;
           }else if(new_pass_value!=new_pass_confirm_value){
               new_pass_confirm_obj.setAttribute("className","input");
               return false;
           }else{
               return true;
           }
    }
    function tijiao(){
      if(old_psss_onblur(‘username‘,‘old_pass‘)&&func(‘new_password‘,‘new_password_control‘)&&new_password_confirm(‘new_password‘,‘new_password_confirmation‘,‘new_password_confirmation_control‘)){
        document.reform.submit();
       }
    }

</script>
<style type="text/css"  >
     .input{
      border-color:#FF0000;
      border-style:solid;
       }

</style>
</head>
<body>
  <form name="reform" action="" method="post">
     <table align="center">
        <tr>
           <th width="200px" align="left">旧密码:
           </td>
           <td width="300px" colspan="2"><input type="text"  id="username"  onBlur="old_psss_onblur(‘username‘,‘old_pass‘)" onMouseOver="old_pass(‘over‘,event,‘username‘,‘old_pass‘)" onMouseOut="old_pass(‘out‘,event,‘username‘,‘old_pass‘)" style="width:200px">
           </td>

        </tr>
        <tr>
           <th align="left">
              新密码:
           </td>
           <td>
           <input type="password" id="new_password"  onmouseout="showlianxi(‘out‘,event,‘new_password‘,‘new_password_control‘)"  onmousemove="showlianxi(‘over‘,event,‘new_password‘,‘new_password_control‘)"  onBlur="func(‘new_password‘,‘new_password_control‘)" style="width:200px" />
           </td>
           <td><a style="font-size:13px">密码不允许纯数字或字母,长度大于5</a>
           </td>
        </tr>
        <tr>
           <th align="left">
           确认新密码:
           </td>
           <td colspan="2">
           <input type="text" id="new_password_confirmation" onMouseOut="showdiv(‘out‘,event,‘new_password‘,‘new_password_confirmation‘,‘new_password_confirmation_control‘)" onMouseMove="showdiv(‘over‘,event,‘new_password‘,‘new_password_confirmation‘,‘new_password_confirmation_control‘)" onBlur="new_password_confirm(‘new_password‘,‘new_password_confirmation‘,‘new_password_confirmation_control‘)"  style="width:200px"/>
           </td>
        </tr>
        <tr>
          <td colspan="3" align="center">
            <input type="button" value="提交" onClick="tijiao()">          </td>
        </tr>
     </table>
     <div id="showlianxi" style="display:none;filter:alpha(opacity=50); background: #FF9999">
    <label id="lable1"></label>
    </div>
    <label id="old_pass" style="display:none">0</label>
    <label id="new_password_control" style="display:none">0</label>
    <label id="new_password_confirmation_control" style="display:none">0</label>
</form>

</body>
</html>

原文地址:https://www.cnblogs.com/lq13035130506/p/10459781.html

时间: 2024-10-19 21:42:58

测试源码的相关文章

一份抢红包测试源码

Jenkins 插件: https://updates.jenkins-ci.org/download/plugins/ 小米的一份android源码,测试工具,用于抢红包: https://github.com/xiaomi/luckymoneytool

checkpoint-BLCR部署和测试(源码)

1. 概述2. 部署过程2.1 源码下载2.2 解压安装2.3 添加库环境2.4 插入内核模块3. 测试3.1 创建测试程序3.2 功能测试4. 参考博客 1. 概述 checkpoint 2. 部署过程 2.1 源码下载 官方网站:http://crd.lbl.gov/departments/computer-science/CLaSS/research/BLCR/ 下载最新版本:blcr-0.8.5.tar.gz 2.2 解压安装 执行命令:tar -zxvf blcr-0.8.5.tar.

easeChat模块demo实现静态聊天窗口测试源码分享

easeChat模块demo(vue+api实现会话列表滑动删除静态,我曾用于手机推币城APP中的房间用户聊天功能)聊天窗口界面静态页面,发送文本消息/消除最新消息/监听消息等环信的接口数据交互功能 *****使我代码的时候,一定记住config.xml里面,关于环信的value,环信开发控制台官网申请key,vuale修改完之后,上传到云端编译才会有效******* message_frm.html代码片段 置顶删除暂时没有做动态数据交换,只是实现了静态功能,留下的点击删除置顶事件,数据交互功

cocos Creator js 房卡麻将/血战/H5四川麻将源码下载搭建

房卡麻将/血战/H5四川麻将 源码 支持iOS/Android/H5 完整源码 1.基于NODEJS+MYSQL的服务器,成熟的技术方案,高效稳定,且方便Windows开发,Linux平台布署,节约服务器运转成本. 2.采用最新版本的cocos引擎,cocos creator开发,可快速的进行界面调整.且能够快速地发布iOS,Android版本. 3.如需H5版本,只需针对H5平台进行资源优化即可. 4.成熟可靠的房卡式设计,能满足大部分用户使用体验. 5.产品经过大量测试,可以运转稳定. 测试

cocos2dx 3.10 网狐经典版PC手机端三网通源码搭建

在网狐棋牌架设中肯定会存在大大小小的难题,今天给大家分享在架设中出现 游戏房间连接失败处理,怎么处理. 测试源码来自maliwl.com 输入帐号密码,能进入大厅,大厅下载游戏也正常,当子游戏下载安装完运行时候就提示上面的错误. 从后台找到客户端,又找到服务端也没解决.无意中翻看数据库发现了解决方法. 打开数据库,QPPlatformDB--DataBaseInfo表 DBInfoID的值 和服务端的ServerParameter.ini里BindMachineID是否一样.也就是说每个ID对应

Lua 源码试读

开始看 Lua 源码也有段时间了,由于尝试用各种方式切入,效果均不是很理想,应该是个人内功不做所致.加上先阶段个人时间有限,现记录下断点,待到来日能力足够有兴趣时再来看. 初期探索: 0.由于第一次尝试读源码,开始时竟将源码按大小顺序排列,从小文件看起. 1.尝试从数据结构看起,看完了 Lua 的数据结构后对 Lua 的数据结构还是有种朦胧的感觉.然后尝试看 Lua 的 GC 终止. 2.尝试把 Lua 当作一个程序来看,从 main 函数开始读,函数调用层层深入下去...作为一个菜鸟,这注定是

棋牌搭建教程之最新傲玩至尊版手机棋牌源码架设技巧

傲玩至尊版是市面上运营功能完善平台:主要功能包括:排行版.VIP.ID复制.银行(存.取.赠送).商城(充值元宝.开通VIP.奖券兑换.购买道具,房卡).战绩(游戏录像回放,查看别人录像,分享录像).活动(每日任务.成就任务.奖券任务).任务(每日任务.成就任务.奖券任务).好友(相册.送礼,签名).比赛.跑马灯.代理系统.运营分析系统.游戏后台管理系统.房卡销售系统.搭建测试源码来自maliwl.com

【c#源码】安卓客户端通过TCP通信与Windows服务器进行文件传输

APK文件  (对应的windows服务器端已经架设好,可以直接下载进行测试) 源码     数据库文件 在前面一篇文章:[源码]c#编写的安卓客户端与Windows服务器程序进行网络通信 中我们探讨了,如何通过xamarin技术,完成安卓客户端与Windows服务器的通信,这篇文章,我们探讨一下使用场景非常多的文件传输. 先谈一下为什么使用xamarin.android技术吧,之前有开发过一个公文系统,c#语言开发,服务器部署在Windows Server 2003上,客户端采用Winform

微信小程序-整理各种小程序源码和资料免费下载

微信小程序整理下载 [小程序源码]微信小程序-车源宝微信版 [小程序源码]小程序-微赞社区(论坛demo) [小程序源码]微信小程序-收支账单 [小程序工具]微信小程序-日历 [小程序源码]小程序-在线聊天功能 [小程序源码]微信小程序-大好商城(新增功能天气查询和2048游戏) [小程序源码]微信小程序-查询号码归属地 [小程序源码]微信小程序-备忘录2 [小程序源码]微信小程序-QQ音乐 [小程序源码]小程序-货币汇率 [小程序源码]微信小程序-大学图书馆 [小程序源码]小程序-积分商城 [