代码结构:
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>账 号:</td> <td> <input type="text" name="name" id="name"/> <div id="nameError" style="display:inline;color:red;"></div> </td> </tr> <tr> <td>密 码:</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