user.jsp
资源名称:(J2EE)oa.rar [点击查看]
上传用户:lm2018
上传日期:2015-12-12
资源大小:30449k
文件大小:9k
源码类别:
Jsp/Servlet
开发平台:
Java
- <%@ page language="java" pageEncoding="GBK"%>
- <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
- <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
- <%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
- <%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>
- <html>
- <head>
- <script>
- var xmlhttp_request = false;
- function initrequest(){
- if(window.XMLHttpRequest){//这种就是Mozilla
- xmlhttp_request = new XMLHttpRequest();
- }else if(window.ActiveXObject){//这种浏览器是IE
- try{
- xmlhttp_request = new ActiveXObject("Msxml2.XMLHttp");
- }catch(e){
- try{
- xmlhttp_request = new ActiceXObject("microsoft.XMLHttp");
- }catch(e){
- }
- }
- }
- if(!xmlhttp_request){
- alert("您的浏览器不支持Ajax");
- return false;
- }
- }
- function processRequest(){
- if(xmlhttp_request.readystate==4){
- //完成返回结果,处理
- if(xmlhttp_request.status==200){
- //正确结果返回处理
- document.getElementById("result").innerHTML = xmlhttp_request.responseText;
- }else{
- //返回结果错误时的处理
- }
- }else{
- //未完成处理中...
- }
- }
- function ajaxcheck(){
- initrequest();
- xmlhttp_request.onreadystatechange=processRequest;
- var uname = document.getElementById("uname").value;
- var url = "user.do?method=checkName&uname="+uname+"&sessid="+Math.random();
- xmlhttp_request.open("post",url,true);//发送请求到服务器
- xmlhttp_request.send(null);//可以传递文件,流,字符串
- }
- function checkform(){
- var uname=document.getElementById("uname");
- if(uname.value.length<=0){
- alert('用户名不能为空!');
- uname.focus();
- return false;
- }
- var deptcheck = document.getElementById("did");
- if(deptcheck.value=="-1"){
- alert('请选择部门!');
- return false;
- }
- var utruename=document.getElementById("utruename");
- if(utruename.value.length<=0){
- alert('真实姓名不能为空!');
- utruename.focus();
- return false;
- }
- <%-- 数组--%>
- var role = document.getElementsByName("frole");
- var flag = false;
- for(i=0;i<role.length;i++){
- //alert(role[i].checked);
- if(role[i].checked) {
- flag = true;
- break;
- }
- }
- if(!flag) {
- alert("请为用户分配角色!");
- return false;
- }
- var uphone = document.getElementById("uphone");
- if(uphone.value != ""){
- //电话号码不是数字的时候,判断
- if(isNaN(uphone.value)){
- //判断第三第四是否为 ‘-’,且只有一个
- if((uphone.value.charAt(3)=='-' || uphone.value.charAt(4)=='-')&(
- (uphone.value.indexOf('-'))==(uphone.value.lastIndexOf('-')))){
- var phonepart = uphone.value.split('-');
- //判断被 '-' 分成的两部分是否都为数字
- if(isNaN(phonepart[0]) || isNaN(phonepart[1])){
- alert('电话号码格式不正确!');
- return false;
- }
- else{
- //判断后面部门是否是7或8位数字
- if(!(phonepart[1].length==7 || phonepart[1].length==8)){
- alert('电话号码长度不对!');
- return false;
- }
- }
- }
- else{
- alert('电话号码格式不正确!');
- return false;
- }
- }//电话号码是数字的时候,判断
- else{
- alert('电话号码格式不正确!');
- return false;
- }
- }else{
- alert('电话号码不能为空!');
- return false;
- }
- var email = document.getElementById("uemail").value;
- if(email != ""){
- //判断第一个字符不能为@和.
- if((email.charAt(0) =='@') || (email.charAt(0) == '.')){
- alert('邮箱格式不对!例:zpeng_chen@126.com');
- return false;
- }else{
- //判断.与@之间是否有间隔
- if((email.indexOf('.'))-(email.indexOf('@'))<=1){
- alert('邮箱格式错误!');
- return false;
- }else{
- //判断是否只有一个@ 和 只有一个 .
- if(email.indexOf('@') != email.lastIndexOf('@') || email.indexOf('.') != email.lastIndexOf('.')){
- alert('邮箱格式错误!');
- return false;
- }else{
- //判断.后不能为空
- var emailPart = email.split('.');
- if(email.length-emailPart[0].length < 2){
- alert('邮箱格式错误!');
- return false;
- }else{
- //动作
- }
- }
- }
- }
- }else{
- alert('邮箱不能为空!');
- return false;
- }
- }
- function isNumber(){
- if (window.event.keyCode<48 || window.event.keyCode>57){
- window.event.keyCode = 0;
- }
- }
- function loadValue(){
- <logic:present name="rlist" scope="request">
- <logic:iterate id="rlist" name="rlist">
- var rid = document.getElementsByName("role1");
- for(var i=0;i<rid.length;i++){
- if(rid[i].value=="${rlist.rid}"){
- rid[i].checked = "checked";
- }
- }
- </logic:iterate>
- </logic:present>
- }
- </script>
- <style type="text/css">
- <!--
- .STYLE1 {
- font-family: "新宋体";
- font-size: 14px;
- }
- -->
- </style>
- </head>
- <div align="center"><FONT color="red">${msg}</FONT></div>
- <body onload="loadValue()">
- <html:form action="/user">
- <html:hidden property="method"/>
- <html:hidden property="uno"/>
- <html:hidden property="uislocked"/>
- <html:hidden property="upwd"/>
- <html:hidden property="uisonline"/>
- <html:hidden property="uaddtime"/>
- <table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#66CCFF" class="STYLE1">
- <tr class="tableHead" style="font-size: 20px">
- <td height="46" colspan="2" align="center"><STRONG>用户信息编辑</STRONG></td>
- </tr>
- <tr>
- <td width="120"><div align="right" >用户名:</div></td>
- <td><html:text onblur="ajaxcheck();" property="uname" style=" width:100px" maxlength="15"/>
- <font color="#FF0000">* <SPAN id="result"></SPAN></font></td>
- </tr>
- <tr>
- <td width="120"><div align="right">真实姓名:</div></td>
- <td>
- <html:text property="utruename" style=" width:100px" maxlength="15"/>
- <font color="#FF0000">*</font></td>
- </tr>
- <tr>
- <td><div align="right">所属部门:</div></td>
- <td>
- <html:select property="did" >
- <html:option value="-1">请选择</html:option>
- <logic:present name="deptlist" scope="request">
- <logic:iterate id="dept" scope="request" name="deptlist">
- <html:option value="${dept.did}">${dept.dname}</html:option>
- </logic:iterate>
- </logic:present>
- </html:select>
- </td>
- </tr>
- <tr>
- <td><div align="right">性别:</div></td>
- <td>
- <html:radio property="usex" value="1"/>男
- <html:radio property="usex" value="0" />女
- </td>
- </tr>
- <tr>
- <td><div align="right">籍贯:</div></td>
- <td>
- <html:text size="15" property="uarea"/> 如:福建福州
- </td>
- </tr>
- <tr>
- <td><div align="right">联系电话:</div></td>
- <td>
- <html:text property="uphone" maxlength="13" size="20"/>
- <font color="#FF0000">*</font> 由区号-电话号码组成,如:0591-12341234
- </td>
- </tr>
- <tr>
- <td><div align="right">E_MAIL:</div></td>
- <td>
- <html:text property="uemail" maxlength="30" size="30"/>
- <font color="#FF0000">*</font> 如:fz163@163.com
- </td>
- </tr>
- <tr>
- <td><div align="right">手机号码:</div></td>
- <td>
- <html:text property="umobile" maxlength="11" size="16" onkeypress="isNumber()"/>
- <font color="#FF0000">*</font>
- </td>
- </tr>
- <tr>
- <td><div align="right">住址:</div></td>
- <td>
- <html:text property="uaddress" size="80"/>
- </td>
- </tr>
- <tr>
- <td><div align="right">工作职位:</div></td>
- <td>
- <html:select property="uwork">
- <html:option value="">请选择</html:option>
- <logic:present name="worklist" scope="request">
- <logic:iterate id="work" scope="request" name="worklist">
- <html:option value="${work.pid}">${work.pname}</html:option>
- </logic:iterate>
- </logic:present>
- </html:select>
- </td>
- </tr>
- <tr>
- <td><div align="right">是否已婚:</div></td>
- <td>
- <html:radio property="uismarryed" value="1" />已婚
- <html:radio property="uismarryed" value="0" />未婚
- </td>
- </tr>
- <tr>
- <td><div align="right">身份证号码:</div></td>
- <td><html:text onkeypress="isNumber()" property="uidcard" maxlength="18">320010123456789589</html:text>
- <font color="#FF0000">*</font></td>
- </tr>
- <tr>
- <td><div align="right">备注:</div></td>
- <td>
- <html:textarea property="umemo" cols="50" rows="5">备注说明</html:textarea>
- </td>
- </tr>
- <tr>
- <td><div align="right">角色分配:</div></td>
- <td>
- <logic:present name="rolelist" scope="request">
- <logic:iterate id="role" scope="request" name="rolelist">
- <input type="checkbox" id="frole" name="role1" value="${role.rid}"/>${role.rname}<br>
- </logic:iterate>
- </logic:present>
- </td>
- </tr>
- <tr>
- <td colspan="2"><div align="center">
- <html:submit onclick="return checkform();" value="提交" />
- <html:reset value="重置" /></div>
- </td>
- </tr>
- </table>
- </html:form>
- </body>
- </html>