⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 modifyinfo.jsp

📁 jsp实现的论坛 使用jsp+servlet+mysql 开发环境是myeclipes
💻 JSP
字号:
<%@ page language="java" import="java.util.*,entity.User" pageEncoding="gbk"%>
<jsp:directive.page import="entity.User;"/>
<%
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>
    <base href="<%=basePath%>">
    
    <title>My JSP 'modifyinfo.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

<script language="JavaScript">

var agePattern=/^[1-9]\d{1}$/;
var qqPattern=/^[1-9]\d{4,8}$/;

function check(){
  var objForm=document.modifyuser_info;

  var strpas=objForm.password.value;
  var strpas2=objForm.password2.value;  
  if(strpas=="" || strpas2=="" ){
    alert("请输入密码或确认密码!");
    event.returnValue=false;
  }
  else if(strpas2!=strpas){
    alert("确认密码与密码不一致,请重新输入!" );
    event.returnValue=false;
  }
  else if(strpas.length<6 || strpas.length>8 || strpas2.length<6 || strpas2.length>8 ){
    alert("确认密码与密码长度必须大于等于6个字符小于等于8个字符!请重新输入!" );
    event.returnValue=false;
  }
  
  var strage=objForm.age.value;
  if((strage!="") && (!agePattern.test(strage))){
    alert("年龄只能为两位数字(>=10 and <=99)!请重新输入!");
    event.returnValue=false;
  }
  
  var strqq=objForm.qq.value;
  if(strqq!="" && !qqPattern.test(objEle.value)){
    alert("QQ只能为数字且在5位数和9位数之间!请重新输入!");
    event.returnValue=false;
  }
  alert("OK!");
  
}

function checkPas(){
  var objForm=document.modifyuser_info;
  var strpas=objForm.password.value;
  var strpas2=objForm.password2.value;
  if(strpas=="" || strpas2=="" ){
    alert("没有输入密码或确认密码!请重新输入!")
    
  }
  else if(strpas2!=strpas){
    alert("确认密码与密码不一致,请重新输入!" );
    
  }
  else if(strpas.length<6 || strpas.length>8 || strpas2.length<6 || strpas2.length>8 ){
    alert("确认密码与密码长度必须大于等于6个字符小于等于8个字符!请重新输入!" );
    
  }
}
function checkAge(objEle){

  if(objEle.value!="" && !agePattern.test(objEle.value)){
    alert("年龄只能为两位数字且(>=10 and <=99)!请重新输入!");
    
  }
}
function checkQq(objEle){

  if(objEle.value!="" && !qqPattern.test(objEle.value)){
    alert("QQ只能为数字且在5位数和9位数之间!请重新输入!");
    
  }
}
</script>



  </head>
  
  <body bgcolor="#C0DFFD">修改个人资料<br>
  <%HttpSession ss=request.getSession();
     User user= (User )   ss.getAttribute("user");
     user.getId();
     //out.print(user.getName());
  
  
   %>
  <br><form method="post" name="modifyuser_info" onsubmit="check()" action="/forum/servlet/Control?op=modify"><table width="335" border="0" align="center" height="245">
<tbody><tr>
<td>&nbsp;用户名</td>
<td>&nbsp;<input type="text" name="id" value="<%=user.getId()%>" disabled></td></tr>
<tr>
<td>&nbsp;密码</td>
<td>&nbsp;<input type="password" name="password" value="<%=user.getPassword()%>"></td></tr>
<tr>
<td>&nbsp;确认密码</td>
<td>&nbsp;<input type="password" name="password2" onblur="checkPas(this)" value="<%=user.getPassword()%>"></td></tr>

<tr>
<td>&nbsp;年龄</td>
<td>&nbsp;<input type="text" name="age" onblur="checkAge(this)" value="<%=user.getAge()%>"></td></tr>
<tr>
<td>&nbsp;性别</td>
<% if(user.getSex().equals("F"))
{%>
<td>男<input type="radio" checked="true" value="F" name="sex">女<input type="radio" value="M" name="sex"></td></tr>
<%}
else { %>
<td>男<input type="radio" value="F" name="sex">女<input type="radio"  checked="true" value="M" name="sex"></td></tr>

<%} %>
<tr>
<td>&nbsp;姓名</td>
<td>&nbsp;<input type="text" name="name" onblur="checkName(this)" value="<%=user.getName()%>"></td></tr>
<tr>
<td>&nbsp;QQ</td>
<td>&nbsp;<input type="text" name="qq" onblur="checkQq(this)" value="<%=user.getQq()%>"></td></tr>
<tr><td colspan=2 align="center"><input  type="submit" value="提交" name="ok" ></td>

</tbody></table> 
<div align="center"><input type="Button" name="return" value="返回" action="" onclick="window.history.back()"/></div>

</form>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -