`

动态的给table添加tr td (js+xmlHttpRequest+struts2)

    博客分类:
  • js
阅读更多
<%@ page contentType="text/html; charset=utf-8" language="java"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<html>
<script type="text/javascript"
src="<%=request.getContextPath()%>/scripts/js/validator_rule.js"></script>
<script type="text/javascript"
src="<%=request.getContextPath()%>/scripts/js/calendarNew.js"></script>
<script type="text/javascript"
src="<%=request.getContextPath()%>/scripts/js/checkdate.js"></script>
<head>
<title></title>
<SCRIPT language="JavaScript" type="text/javascript">
var num = '<s:property value="iapsMainAppiList.size" />';
var xmlhttp;

// 获取 XMLHttpRequest;
function createxmlhttp() {
  var xmlhttp;
   if (window.ActiveXObject) {
     xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   }
   else if (window.XMLHttpRequest) {
     xmlhttp = new XMLHttpRequest();
   }
   return xmlhttp;
}
/*
// 回调函数
function handleStateChange(isBlean) {
// 这里 返回 对象的主见 id 
        if (xmlhttp.readyState == 4) {
          if (xmlhttp.status == 200) {
            // document.getElementById("t2").value=xmlhttp.responseText;
              var appiId = "<s:property value="appiId" />";
              if(appiId){
alert("新增成功");
              }else{
alert("新增失败");
              }
          // alert("新增成功");
          }
        }
    }*/

function delRow() {
try {
//判断行数是否小于等于已保存的信息条数+1(+1是因为表头的存在)
var billTable = document.getElementById('billTable');
if (billTable.rows.length <= (parseInt(num) + 1)) {
alert("已保存的申请件信息不能删除!");
return;
}
billTable.deleteRow(billTable.rows.length-1);
} catch (e) {
alert("Err 5001:\r\n" + e.message);
}
}

function addRow() {
try {
// 清空以前的 数据 信息 
phoneArr = new Array();

var billTable = document.getElementById('billTable');

//复制最后一行      先复制 否则置灰的属性就会也被复制
var otr = billTable.rows[billTable.rows.length-1];
var newtr = otr.cloneNode(true);

//验证最后一行的数据是否完整,checkRowBatchQcc方法接收的为iapsMainAppiList列表的索引,所以除去表头一行,并且转成索引形式,所以为-2
var messArr = checkRowBatchQcc(billTable.rows.length-2);

var mess = messArr[0] ;              // 错误信息
var parameters = messArr[1] ;        // 参数
var rowindex = messArr[2] ;          // 行数  / td的主键appid

var appiBatchfile = "<s:property value="appiBatchfile" />" ;
parameters += "&appiBatchfile=" + appiBatchfile ;

//alert("message:" + mess);
alert("parameters:" + parameters);

// 这里对电话号码数据 进行次数效验
mess = validPhone(mess) ;

document.getElementById('messageDiv').innerText = mess;
if(mess != ''){
alert('数据发生逻辑心错误,不能添加新行!');
return ;
}else{
var cel = document.getElementById('iapsMainAppiList'+(billTable.rows.length-2)).cells[1];
cel.innerHTML = parseInt(cel.innerText);

// 通过ajax 想服务器端发起请求 
url = "<%=request.getContextPath()%>/batch/batchQccAction_saveOneBatchQcc.action" ;
xmlhttp = createxmlhttp();
            xmlhttp.open("POST",url,true);
            xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;");
            xmlhttp.send(parameters);  // 传递参数
            xmlhttp.onreadystatechange = function(){
            if (xmlhttp.readyState == 4) {
                    if (xmlhttp.status == 200) {
                        // document.getElementById("t2").value=xmlhttp.responseText;
                        var appiId = xmlhttp.responseText;
                        alert("====appiId:" + appiId + "----rowindex:" + rowindex);
                        // var appiAppIdObj = document.getElementById("iapsMainAppiList["+rowindex+"].appiAppId");
                        if(appiId){
                        //document.getElementById("iapsMainAppiList[1].appiAppId").value = appiId ;
                        document.getElementById(rowindex).value = appiId ;
                        // alert(document.getElementById('billTable').rows[rowindex].cells[1].innerHTML);
              alert("保存成功");
                        }else{
              alert("保存失败");
                        }
                     }
                  }
              };

}

//替换cells中的对象的id和name所涉及到iapsMainAppiList的索引
var newNode = addId(parseInt(billTable.rows.length-2)+1,newtr);

newNode.id = "iapsMainAppiList"+(parseInt(billTable.rows.length-2)+1);
//特别加上tbody对象,因为直接在table中appendChild对象可能不显示
document.getElementById('bileTableTbody').appendChild(newNode);

//前10列的值不带下来
removeValue(billTable.rows.length-2);

//alert("addRow--num="+num);
//oTBODY.insertAdjacentElement("beforeEnd",newNode);

} catch (e) {
alert("Err 5002:\r\n" + e.message);
}
}
//j表示要增加的行的ID(即,最后一行的ID加1)
//node表示newtr = otr.cloneNode(true);

function addId(j,node) {
try {
var oList = node.childNodes;
for(var i=0;i<oList.length;i++) {
if(i==0||i==1||i==(oList.length-1)){
if(i==1){
oList[i].innerHTML=j+1;
}
}else{
oList[i].innerHTML = oList[i].innerHTML.replace(/\[\d\]/g,"["+j+"]");
}
}
return node;
}catch (e) {
alert("Err 5003:\r\n" + e.message);
}
}

/**
* 根据产品ID获得产品卡面
* prefix:ID前缀,主要是为了获取集合下标
* setValue:该方法是通过改变产品类型而来使主卡版面发生改变,该参数是要设置的主卡版面的值
*/
function changAppiProdCatCode(prefix){
createXMLHttpRequest();
var url = "<%=request.getContextPath()%>/company/companyInf_changCatCode.action";
xmlHttp.onreadystatechange = function(){
if(xmlHttp.readyState == 4 && xmlHttp.status == 200){
var appiMcComName = xmlHttp.responseText;
alert(appiMcComName = '-------');
var appiMcComNames = (appiMcComName.split("---")[0]).split("||");

strDutyNum= appiMcComName.split("---")[1];
var appiMcDispartComNamelist = document.getElementById(prefix + ".appiMcColor");
appiMcDispartComNamelist.length=0;
appiMcDispartComNamelist.add(new Option("请选择",""));
for(var j=0;j<appiMcComNames.length-1;j++){
var resultValue =appiMcComNames[j].split("===")[0];
var resultText =appiMcComNames[j].split("===")[1];
var resultOption = new Option(resultText,resultValue);
appiMcDispartComNamelist.add(resultOption);
}
      }
};
xmlHttp.open('POST', url, true);
xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xmlHttp.send("proCatCode=" + document.getElementById(prefix+'.appiProdCatCode').value);
}

var xmlHttp;
function createXMLHttpRequest() {
if(window.XMLHttpRequest){ //Mozilla
xmlHttp = new XMLHttpRequest();
}else if (window.ActiveXObject){ // IE
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
}catch (e){
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
}

function calELength(value){
var pa = /[^x00-xff]/;
var array = value.split('');
var prvIsChinese = false;
var eLength = 0 ;
for(var i = 0 ; i < array.length ; i ++){
var temp = array[i];
if(pa.test(temp)){
if(prvIsChinese == true){
eLength += 2;
}else{
eLength += 4;
}
prvIsChinese = true;
}else{
eLength += 1;
prvIsChinese = false;
}
}
return eLength;
}

function showErrorMessage(mge){
document.getElementById('messageDiv').innerText = mge;
}
</SCRIPT>
<style>
.R_th {
white-space: nowrap;
text-align: center
}
;
.R_main(
white-space
:nowrap
;)
</style>
</head>
<body bgcolor="#e8e8e8">
<form name="form1"
action="<%=request.getContextPath()%>/batch/batchQccAction_inputBatchQcc.action"
method="post"><input value="0," name="allrow" id="allrow"
type="hidden">
<tr class="R_main">
<td class="R_main" colSpan="10">批次号:<s:property
value="appiBatchfile" /> <input type="hidden" name="appiBatchfile" id="appiBatchfile"
value="<s:property value="appiBatchfile" />" />
<div align="right"><input type="button" value="返回" class="btn"
onclick="goBack()" /><input type="button" value="保存" class="btn"
onClick="checkBatchQcc();" /></div>
</td>
</tr>
<div id="messageDiv" style="color: red;"></div>
<table width="100%" border="1" cellpadding="1" cellspacing="1"
id="billTable">
<tbody id="bileTableTbody">
<tr class="R_th" bgcolor="#3399CC">
<td class="R_th"></td>
<td class="R_th"></td>
<td class="R_th" align="center"><FONT color="red">*</FONT>产品类型</td>
<td class="R_th" align="center"><FONT color="red">*</FONT>主卡版面</td>
<td class="R_th" align="center"><FONT color="red">*</FONT>称谓</td>
<td class="R_th" align="center"><FONT color="red">*</FONT>姓</td>
<td class="R_th" align="center"><FONT color="red">*</FONT>名</td>
<td class="R_th" align="center"><FONT color="red">*</FONT>姓名拼音</td>
<td class="R_th" align="center">第二印花名</td>
<td class="R_th" align="center"><FONT color="red">*</FONT>证件类型</td>
<td class="R_th" align="center"><FONT color="red">*</FONT>证件号码</td>
<td class="R_th" align="center"><FONT color="red">*</FONT>持卡人生日</td>
<td class="R_th" align="center"><FONT color="red">*</FONT>证件有效期截至日期</td>
<td class="R_th" align="center"><FONT color="red">*</FONT>证件有效期长期标识(长期)</td>
<td class="R_th" align="center"><FONT color="red">*</FONT>国籍</td>
<td class="R_th" align="center"><FONT color="red">*</FONT>住宅地址(省/直辖市)</td>
<td class="R_th" align="center"><FONT color="red">*</FONT>住宅地址(市/区/县)</td>
<td class="R_th" align="center"><FONT color="red">*</FONT>住宅地址一</td>
<td class="R_th" align="center">住宅地址二</td>
<td class="R_th" align="center">住宅地址三</td>
<td class="R_th" align="center">住宅邮编</td>
<td class="R_th" align="center"><FONT color="red">*</FONT>持卡人手机号码</td>
<td class="R_th" align="center"><FONT color="red">*</FONT>单位名称</td>
<td class="R_th" align="center">单位邮编</td>
<td class="R_th" align="center"><FONT color="red">*</FONT>单位地址(省/直辖市)</td>
<td class="R_th" align="center"><FONT color="red">*</FONT>单位地址(市/区/县)</td>
<td class="R_th" align="center"><FONT color="red">*</FONT>单位地址一</td>
<td class="R_th" align="center">单位地址二</td>
<td class="R_th" align="center">单位地址三</td>
<td class="R_th" align="center"><FONT color="red">*</FONT>主卡对帐单及领卡邮寄地址</td>
<td class="R_th" align="center"><FONT color="red">*</FONT>母亲姓氏</td>
<td class="R_th" align="center"><FONT color="red">*</FONT>联系人姓名</td>
<td class="R_th" align="center"><FONT color="red">*</FONT>联系人电话</td>
<td class="R_th" align="center">联系人与申请人关系</td>
<td class="R_th" align="center">联系人单位</td>
<td class="R_th" align="center"><FONT color="red">*</FONT>长城信用卡主卡所在地</td>
<td class="R_th" align="center"><FONT color="red">*</FONT>免年费类型FW</td>
<td class="R_th" align="center"><FONT color="red">*</FONT>BH号</td>
<td class="R_th" align="center">银行专用信息推荐员工标识IN</td>
<td class="R_th" align="center"><FONT color="red">*</FONT>总行端制卡参数选择</td>
<td class="R_th" align="center"><FONT color="red">*</FONT>POS验密参数</td>
<td class="R_th" align="center">淘宝卡帐户类型</td>
<td class="R_th" align="center">电子邮箱</td>
<td class="R_th" align="center">毕业年份</td>
<td class="R_th" align="center">领卡分行号</td>
<td class="R_th" align="center">单位编号</td>
<td class="R_th"></td>
</tr>
<s:iterator id="iapsMainAppi" value="iapsMainAppiList" status="ii">
<tr class="R_main"
id="iapsMainAppiList<s:property value="#ii.index" />">
<td class="R_main" width="50">
<BUTTON onClick="addRow()" type="button"
class="btn">+</BUTTON>
<s:if test="#ii.index > 0">
<script language="JavaScript" type="text/javascript">
document.getElementById('allrow').value += <s:property value="#ii.index" /> + ",";
</script>
</s:if></td>
<td class="R_th"><s:property value="#ii.index + 1" /><input
type="hidden"
id="iapsMainAppiList[<s:property value="#ii.index" />].appiAppId"
name="iapsMainAppiList[<s:property value="#ii.index" />].appiAppId"
value="<s:property value="appiAppId" />" /></td>
<td class="R_main"><select 
name="iapsMainAppiList[<s:property value="#ii.index" />].appiProdCatCode"
id="iapsMainAppiList[<s:property value="#ii.index" />].appiProdCatCode"
onchange="changAppiProdCatCode('iapsMainAppiList[<s:property value="#ii.index" />]');">
<s:iterator value="getAllProdcat()">
<option value="<s:property value="proCatCode" />"
<s:if test="#iapsMainAppi.appiProdCatCode == proCatCode">selected="selected"</s:if>
cardTypeFlag="<s:property value="cardTypeFlag" />"><s:property
value="proCatName" /></option>
</s:iterator>
</select></td>
<td class="R_main"><select
name="iapsMainAppiList[<s:property value="#ii.index" />].appiMcColor"
id="iapsMainAppiList[<s:property value="#ii.index" />].appiMcColor"
onfocus="aa(this)">
<option value="">请选择</option>
<s:iterator value="getProdcatById(appiProdCatCode).productColor">
<option value="<s:property value="colorId" />"
<s:if test="#iapsMainAppi.appiMcColor == colorId">selected="selected"</s:if>><s:property
value="colorName" /></option>
</s:iterator>
</select></td>
<td class="R_main"><select
name="iapsMainAppiList[<s:property value="#ii.index" />].appiMcTitle">
<option value="1"
<s:if test="appiMcTitle == 1">selected="selected"</s:if>>1先生</option>
<option value="2"
<s:if test="appiMcTitle == 2">selected="selected"</s:if>>2女士</option>
</select></td>
<td class="R_main"><input type="text"
name="iapsMainAppiList[<s:property value="#ii.index" />].appiMcFirstName"
id="iapsMainAppiList[<s:property value="#ii.index" />].appiMcFirstName"
size="6" onFocus="aa(this);"
value="<s:property value="appiMcFirstName" />" /></td>
<td class="R_main"><input type="text"
name="iapsMainAppiList[<s:property value="#ii.index" />].appiMcFamilyname"
id="iapsMainAppiList[<s:property value="#ii.index" />].appiMcFamilyname"
value="<s:property value="appiMcFamilyname" />" size="6"
onFocus="aa(this);" /></td>
<td class="R_main"><input type="text" disabled=true
name="iapsMainAppiList[<s:property value="#ii.index" />].appiMcKnowAsName1"
id="iapsMainAppiList[<s:property value="#ii.index" />].appiMcKnowAsName1"
value="<s:property value="appiMcKnowAsName1" />" size="15"
maxlength="28" onFocus="aa(this);" /></td>
<td class="R_main"><input type="text"
name="iapsMainAppiList[<s:property value="#ii.index" />].appiMcKnowAsName2"
id="iapsMainAppiList[<s:property value="#ii.index" />].appiMcKnowAsName2"
value="<s:property value="appiMcKnowAsName2" />" size="15"
maxlength="13" onFocus="aa(this);" /></td>
<td class="R_main"><select style="WIDTH: 150px"
name="iapsMainAppiList[<s:property value="#ii.index" />].appiMcIdType"
id="iapsMainAppiList[<s:property value="#ii.index" />].appiMcIdType"
onchange="changeAppiMcIdType(this.value,<s:property value="#ii.index" />);">
<s:iterator status="index" value="getListByType('appi_mc_id_type')">
<option value="<s:property value="bizTypePropCode"/>"
<s:if test="#iapsMainAppi.appiMcIdType==bizTypePropCode">selected</s:if>>
<s:property value="bizTypePropCode" /><s:property
value="bizTypePropName" />
</s:iterator>
</select></td>
<td class="R_main"><input type="text"
name="iapsMainAppiList[<s:property value="#ii.index" />].appiMcIdNumber"
id="iapsMainAppiList[<s:property value="#ii.index" />].appiMcIdNumber"
value="<s:property value="appiMcIdNumber" />" size="20"
maxlength="20" onFocus="aa(this);"
onblur="setAppiMcDob(this,<s:property value="#ii.index" />)" /></td>
<td class="R_main"><input type="text"
name="iapsMainAppiList[<s:property value="#ii.index" />].appiMcDob"
id="iapsMainAppiList[<s:property value="#ii.index" />].appiMcDob"
value="<s:property value="appiMcDobStr" />" size="10" maxlength="10"
style="cursor: pointer;" onblur="validatorDate(this)"
onfocus="aa(this)" /></td>
<td class="R_main"><input type="text"
name="iapsMainAppiList[<s:property value="#ii.index" />].appiMcValidEndDate"
id="iapsMainAppiList[<s:property value="#ii.index" />].appiMcValidEndDate"
value="<s:property value="appiMcValidEndDate" />" size="10"
maxlength="10" onFocus="aa(this);" onfocus="calendar(this);"
onblur="validatorDate(this)" /></td>
<td class="R_main" align="center"><s:if
test="appiMcValidLongFlag == 1">
<input type="checkbox"
name="iapsMainAppiList[<s:property value="#ii.index" />].appiMcValidLongFlag"
id="iapsMainAppiList[<s:property value="#ii.index" />].appiMcValidLongFlag"
value="1" checked="checked" />
</s:if> <s:else>
<input type="checkbox"
name="iapsMainAppiList[<s:property value="#ii.index" />].appiMcValidLongFlag"
id="iapsMainAppiList[<s:property value="#ii.index" />].appiMcValidLongFlag"
value="1" />
</s:else></td>
<td class="R_main"><input type="text"
name="iapsMainAppiList[<s:property value="#ii.index" />].appiMcNationality"
id="iapsMainAppiList[<s:property value="#ii.index" />].appiMcNationality"
value="<s:property value="appiMcNationality == null ? 'CHN' : appiMcNationality" />"
size="6" maxlength="3" onFocus="aa(this);" /></td>
<td class="R_main"><input type="text" disabled=true
name="iapsMainAppiList[<s:property value="#ii.index" />].appiMcAddrState"
id="iapsMainAppiList[<s:property value="#ii.index" />].appiMcAddrState"
value="<s:property value="appiMcAddrState" />" size="20"
onFocus="aa(this);" /></td>
<td class="R_main"><input type="text"
name="iapsMainAppiList[<s:property value="#ii.index" />].appiMcAddrCity"
id="iapsMainAppiList[<s:property value="#ii.index" />].appiMcAddrCity"
value="<s:property value="appiMcAddrCity" />" size="20"
onFocus="aa(this);" /></td>
<td class="R_main"><input type="text"
name="iapsMainAppiList[<s:property value="#ii.index" />].appiMcAddr1"
id="iapsMainAppiList[<s:property value="#ii.index" />].appiMcAddr1"
value="<s:property value="appiMcAddr1" />" size="20"
onFocus="aa(this);" /></td>
<td class="R_main"><input type="text"
name="iapsMainAppiList[<s:property value="#ii.index" />].appiMcAddr2"
id="iapsMainAppiList[<s:property value="#ii.index" />].appiMcAddr2"
value="<s:property value="appiMcAddr2" />" size="20"
onFocus="aa(this);" /></td>
<td class="R_main"><input type="text"
name="iapsMainAppiList[<s:property value="#ii.index" />].appiMcAddr3"
id="iapsMainAppiList[<s:property value="#ii.index" />].appiMcAddr3"
value="<s:property value="appiMcAddr3" />" size="20"
onFocus="aa(this);" /></td>
<td class="R_main"><input type="text"
name="iapsMainAppiList[<s:property value="#ii.index" />].appiMcPostCode"
id="iapsMainAppiList[<s:property value="#ii.index" />].appiMcPostCode"
value="<s:property value="appiMcPostCode" />" size="6" maxlength="6"
onFocus="aa(this);" /></td>
<td class="R_main"><input type="text"
name="iapsMainAppiList[<s:property value="#ii.index" />].appiMcMPhone"
id="iapsMainAppiList[<s:property value="#ii.index" />].appiMcMPhone"
value="<s:property value="appiMcMPhone" />" size="20" maxlength="11"
onFocus="aa(this);" /></td>
<td class="R_main"><input type="text"
name="iapsMainAppiList[<s:property value="#ii.index" />].appiMcEmployerName"
id="iapsMainAppiList[<s:property value="#ii.index" />].appiMcEmployerName"
value="<s:property value="appiMcEmployerName" />"
onFocus="aa(this);" /></td>
<td class="R_main"><input type="text"
name="iapsMainAppiList[<s:property value="#ii.index" />].appiMcEmplPostCode"
id="iapsMainAppiList[<s:property value="#ii.index" />].appiMcEmplPostCode"
value="<s:property value="appiMcEmplPostCode" />" size="6"
maxlength="6" onFocus="aa(this);" /></td>
<td class="R_main"><input type="text"
name="iapsMainAppiList[<s:property value="#ii.index" />].appiMcEmplAddrState"
id="iapsMainAppiList[<s:property value="#ii.index" />].appiMcEmplAddrState"
value="<s:property value="appiMcEmplAddrState" />" size="20"
onFocus="aa(this);" /></td>
<td class="R_main"><input type="text"
name="iapsMainAppiList[<s:property value="#ii.index" />].appiMcEmplAddrCity"
id="iapsMainAppiList[<s:property value="#ii.index" />].appiMcEmplAddrCity"
value="<s:property value="appiMcEmplAddrCity" />" size="20"
onFocus="aa(this);" /></td>
<td class="R_main"><input type="text"
name="iapsMainAppiList[<s:property value="#ii.index" />].appiMcEmplAddr1"
id="iapsMainAppiList[<s:property value="#ii.index" />].appiMcEmplAddr1"
value="<s:property value="appiMcEmplAddr1" />" size="20"
onFocus="aa(this);" /></td>
<td class="R_main"><input type="text"
name="iapsMainAppiList[<s:property value="#ii.index" />].appiMcEmplAddr2"
id="iapsMainAppiList[<s:property value="#ii.index" />].appiMcEmplAddr2"
value="<s:property value="appiMcEmplAddr2" />" size="20"
onFocus="aa(this);" /></td>
<td class="R_main"><input type="text"
name="iapsMainAppiList[<s:property value="#ii.index" />].appiMcEmplAddr3"
id="iapsMainAppiList[<s:property value="#ii.index" />].appiMcEmplAddr3"
value="<s:property value="appiMcEmplAddr3" />" size="20"
onFocus="aa(this);" /></td>
<td class="R_main"><select
id="iapsMainAppiList[<s:property value="#ii.index" />].appiMcBillAddrInd"
name="iapsMainAppiList[<s:property value="#ii.index" />].appiMcBillAddrInd">
<option value="1"
<s:if test="appiMcBillAddrInd == 1">selected="selected"</s:if>>1寄往公司地址</option>
<option value="2"
<s:if test="appiMcBillAddrInd == 2">selected="selected"</s:if>>2寄往住宅地址</option>
</select></td>
<td class="R_main"><input type="text"
name="iapsMainAppiList[<s:property value="#ii.index" />].appiMcMotherName"
id="iapsMainAppiList[<s:property value="#ii.index" />].appiMcMotherName"
value="<s:property value="appiMcMotherName" />" size="4"
onFocus="aa(this);" maxlength="6" /></td>
<td class="R_main"><input type="text"
name="iapsMainAppiList[<s:property value="#ii.index" />].appiMcContactName"
id="iapsMainAppiList[<s:property value="#ii.index" />].appiMcContactName"
value="<s:property value="appiMcContactName" />" size="4"
onFocus="aa(this);" maxlength="6" /></td>
<td class="R_main"><input type="text"
name="iapsMainAppiList[<s:property value="#ii.index" />].appiMcContactMPhone"
id="iapsMainAppiList[<s:property value="#ii.index" />].appiMcContactMPhone"
value="<s:property value="appiMcContactMPhone" />" size="20"
maxlength="11" onFocus="aa(this);" /></td>
<td class="R_main"><select
id="iapsMainAppiList[<s:property value="#ii.index" />].appiMcContactRelship"
name="iapsMainAppiList[<s:property value="#ii.index" />].appiMcContactRelship">
<option value="">请选择</option>
<option value="1"
<s:if test="appiMcContactRelship == 1">selected="selected"</s:if>>1父母</option>
<option value="2"
<s:if test="appiMcContactRelship == 2">selected="selected"</s:if>>2配偶</option>
<option value="3"
<s:if test="appiMcContactRelship == 3">selected="selected"</s:if>>3亲戚</option>
<option value="4"
<s:if test="appiMcContactRelship == 4">selected="selected"</s:if>>4其他</option>
</select></td>
<td class="R_main"><input type="text"
name="iapsMainAppiList[<s:property value="#ii.index" />].appiMcContactEmployer"
id="iapsMainAppiList[<s:property value="#ii.index" />].appiMcContactEmployer"
value="<s:property value="appiMcContactEmployer" />"
onFocus="aa(this);" /></td>
<td class="R_main"><select style="WIDTH: 150px"
name="iapsMainAppiList[<s:property value="#ii.index" />].appiMcConsumeCity"
id="iapsMainAppiList[<s:property value="#ii.index" />].appiMcConsumeCity">
<option value="">请选择</option>
<s:iterator value='getBaseId()'>
<option value="<s:property value='bnCode'/>"
<s:if test="bnCode == #iapsMainAppi.appiMcConsumeCity">selected="selected"</s:if>><s:property
value='bnDesc' /></option>
</s:iterator>
</select></td>
<td class="R_main"><select
id="iapsMainAppiList[<s:property value="#ii.index" />].appiBankinfoFeeType"
name="iapsMainAppiList[<s:property value="#ii.index" />].appiBankinfoFeeType">
<option value="0"
<s:if test="0 == appiBankinfoFeeType">selected="selected"</s:if>>0不免</option>
<option value="1"
<s:if test="1 == appiBankinfoFeeType">selected="selected"</s:if>>1免首年</option>
<option value="2"
<s:if test="2 == appiBankinfoFeeType">selected="selected"</s:if>>2免3年</option>
<option value="3"
<s:if test="3 == appiBankinfoFeeType">selected="selected"</s:if>>3全免</option>
</select></td>
<td class="R_main"><input type="text"
name="iapsMainAppiList[<s:property value="#ii.index" />].appiBankinfoBh"
id="iapsMainAppiList[<s:property value="#ii.index" />].appiBankinfoBh"
value="<s:property value="appiBankinfoBh" />" size="8"
onFocus="aa(this);" maxlength="10" /></td>
<td class="R_main"><input type="text"
name="iapsMainAppiList[<s:property value="#ii.index" />].appiBankinfoPccIn"
id="iapsMainAppiList[<s:property value="#ii.index" />].appiBankinfoPccIn"
value="<s:property value="appiBankinfoPccIn" />" size="12"
onFocus="aa(this);" /></td>
<td class="R_main"><select 
id="iapsMainAppiList[<s:property value="#ii.index" />].packageId"
name="iapsMainAppiList[<s:property value="#ii.index" />].packageId">
<option value="0" <s:if test="0==apsBatchState.batchIsmail">selected="selected"</s:if>>0暂不制卡</option>
<option value="1" <s:if test="1==apsBatchState.batchIsmail">selected="selected"</s:if>>1制卡并邮寄</option>
</select></td>
<td class="R_main"><select
id="iapsMainAppiList[<s:property value="#ii.index" />].appiMcConsume"
name="iapsMainAppiList[<s:property value="#ii.index" />].appiMcConsume">
<option value="1"
<s:if test="1 == appiMcConsume">selected="selected"</s:if>>1密码+签名</option>
<option value="2"
<s:if test="2 == appiMcConsume">selected="selected"</s:if>>2签名</option>
</select></td>
<td class="R_main"><select
id="iapsMainAppiList[<s:property value="#ii.index" />].appiMcAlipayAccountType"
name="iapsMainAppiList[<s:property value="#ii.index" />].appiMcAlipayAccountType">
<option value="">请选择</option>
<option value="1000"
<s:if test="1000 == appiMcAlipayAccountType">selected="selected"</s:if>>1000手机号</option>
<option value="4000"
<s:if test="4000 == appiMcAlipayAccountType">selected="selected"</s:if>>4000电子邮箱</option>
</select></td>
<td class="R_main"><input type="text"
name="iapsMainAppiList[<s:property value="#ii.index" />].appiMcEmailAddr"
id="iapsMainAppiList[<s:property value="#ii.index" />].appiMcEmailAddr"
value="<s:property value="appiMcEmailAddr" />" size="6"
onFocus="aa(this);" /></td>
<td class="R_main"><input type="text"
name="iapsMainAppiList[<s:property value="#ii.index" />].appiMcAssetValue"
id="iapsMainAppiList[<s:property value="#ii.index" />].appiMcAssetValue"
value="<s:property value="appiMcAssetValue" />" size="4"
maxlength="4" onFocus="aa(this);" /></td>
<td class="R_main"><select
name="iapsMainAppiList[<s:property value="#ii.index" />].appiMcOtherCard1Bank"
id="iapsMainAppiList[<s:property value="#ii.index" />].appiMcOtherCard1Bank"
disabled="disabled">
<s:iterator value="cardBankList">
<option value="<s:property value="appiCardId" />"
<s:if test="#iapsMainAppi.appiMcOtherCard1Bank == appiCardId">selected="selected"</s:if>><s:property
value="appiCardId" />/<s:property value="appiCardBankName" /></option>
</s:iterator>
</select></td>
<td class="R_main"><input type="text" disabled=true
name="iapsMainAppiList[<s:property value="#ii.index" />].appiMcOtherCard2Bank"
id="iapsMainAppiList[<s:property value="#ii.index" />].appiMcOtherCard2Bank"
value="<s:property value="appiMcOtherCard2Bank" />" size="8"
onFocus="aa(this);" /></td>
<td>
<button onClick="delRow('allRow')" type="button" class="btn">-</button>
</td>
</tr>
</s:iterator>
</tbody>
</table>
<div><s:property value="precheckMessage" /></div>
</form>
<script type="text/javascript">
//返回
function goBack(){
var appiBatchfile = "<s:property value="appiBatchfile" />" ;
document.form1.action = "<%=request.getContextPath()%>/batch/apsBatchProjectAction_toBatchStateQccList.action?projectPkId=" + appiBatchfile.substr(0,10);
document.form1.submit();
}

// 定义2个数组 用来存取 电话号码  用于 判断该电话号码 出现的次数
// 在点击保存按钮的时候  吧电话号码 存入 数组中  在保存之前进行效验  号码出现的次数 是否已经超出
var phoneArr = new Array();

// 同一个电话号码出现的次数  默认是一次
var phoneCount = 1 ;

// 比较电话号码
function validPhone(message){

for(var i = 0 ; i < phoneArr.length-1 ; i++){
for(var j = i+1 ; j < phoneArr.length ; j++){
// 判断 是否有 重复出现的电话号码
if(phoneArr[i] == phoneArr[j]){
phoneCount = phoneCount + 1 ;
}
}
//  判断 该电话号码出现的次数 是否超过  5 次 
if(phoneCount >= 5){
if(message.indexOf(phoneArr[i])==-1){
message = message + " 持卡人手机号码:" + phoneArr[i] + " 该电话号码已经出现了5次以上  请重新填写 ; "
}
}
// 循环判断一轮后  吧 phoneCount的值 置为 1 ;
phoneCount = 1 ;
}
return message ;
}

function removeValue(rowindex){
document.getElementById("iapsMainAppiList["+rowindex+"].appiMcFirstName").value="";
document.getElementById("iapsMainAppiList["+rowindex+"].appiMcFamilyname").value="";
document.getElementById("iapsMainAppiList["+rowindex+"].appiMcKnowAsName1").value="";
document.getElementById("iapsMainAppiList["+rowindex+"].appiMcKnowAsName2").value="";
document.getElementById("iapsMainAppiList["+rowindex+"].appiMcDob").value="";
document.getElementById("iapsMainAppiList["+rowindex+"].appiMcValidEndDate").value="";
document.getElementById("iapsMainAppiList["+rowindex+"].appiMcAddr2").value = "";
document.getElementById("iapsMainAppiList["+rowindex+"].appiMcAddr3").value = "";
document.getElementById("iapsMainAppiList["+rowindex+"].appiMcMotherName").value="";

//给证件类型绑定时间
var appiMcIdType = document.getElementById("iapsMainAppiList["+rowindex+"].appiMcIdType");
appiMcIdType.onchange = function(){
changeAppiMcIdType(this.value,rowindex);
}

//给证件号的文本框绑定事件
var appiMcIdNumberObj = document.getElementById("iapsMainAppiList["+rowindex+"].appiMcIdNumber");
appiMcIdNumberObj.value = "";
appiMcIdNumberObj.onblur = function(){
setAppiMcDob(this,rowindex);
}



function changeAppiMcIdType(val, rowIndex){
var appiMcDob = document.getElementById('iapsMainAppiList['+rowIndex+'].appiMcDob');
if(1 == val){
appiMcDob.readOnly = true;
appiMcDob.style.cursor = "pointer";
}else{
appiMcDob.readOnly = false;
appiMcDob.style.cursor = "default";
}
}



document.getElementById("iapsMainAppiList["+rowindex+"].appiMcIdNumber").value="";
document.getElementById("iapsMainAppiList["+rowindex+"].appiMcMPhone").value="";

//产品类型,主卡版面,邮寄方式,长城卡使用所在地,免年费类型,制卡参数,验密参数,淘宝卡账户类型,领卡分行,下拉框的赋值
var previousRowIndex = rowindex - 1;


document.getElementById("iapsMainAppiList["+rowindex+"].appiProdCatCode").value = document.getElementById("iapsMainAppiList["+previousRowIndex+"].appiProdCatCode").value;
document.getElementById("iapsMainAppiList["+rowindex+"].appiMcColor").value = document.getElementById("iapsMainAppiList["+previousRowIndex+"].appiMcColor").value;

document.getElementById("iapsMainAppiList["+rowindex+"].appiMcBillAddrInd").value = document.getElementById("iapsMainAppiList["+previousRowIndex+"].appiMcBillAddrInd").value;
document.getElementById("iapsMainAppiList["+rowindex+"].appiMcConsumeCity").value = document.getElementById("iapsMainAppiList["+previousRowIndex+"].appiMcConsumeCity").value;
document.getElementById("iapsMainAppiList["+rowindex+"].appiBankinfoFeeType").value = document.getElementById("iapsMainAppiList["+previousRowIndex+"].appiBankinfoFeeType").value;
document.getElementById("iapsMainAppiList["+rowindex+"].packageId").value = document.getElementById("iapsMainAppiList["+previousRowIndex+"].packageId").value;
document.getElementById("iapsMainAppiList["+rowindex+"].appiMcConsume").value = document.getElementById("iapsMainAppiList["+previousRowIndex+"].appiMcConsume").value;

document.getElementById("iapsMainAppiList["+rowindex+"].appiMcContactRelship").value = document.getElementById("iapsMainAppiList["+previousRowIndex+"].appiMcContactRelship").value;
document.getElementById("iapsMainAppiList["+rowindex+"].appiMcAlipayAccountType").value = document.getElementById("iapsMainAppiList["+previousRowIndex+"].appiMcAlipayAccountType").value;

document.getElementById("iapsMainAppiList["+rowindex+"].appiMcOtherCard1Bank").value = document.getElementById("iapsMainAppiList["+previousRowIndex+"].appiMcOtherCard1Bank").value;
document.getElementById("iapsMainAppiList["+rowindex+"].appiMcOtherCard2Bank").value = document.getElementById("iapsMainAppiList["+previousRowIndex+"].appiMcOtherCard2Bank").value;

}
//数据质检
function checkBatchQcc()
{
    var allrows=document.getElementById("billTable").rows.length - 1;
var rowindex;
var result=0;
// 清空以前的 数据 信息 
phoneArr = new Array(); 
for(var i=0; i < allrows;i++){

var messArr = checkRowBatchQcc(i);
var message = messArr[0] ;

// 这里对电话号码数据 进行次数效验
message = validPhone(message) ;

if(message != ''){
result++;
document.getElementById('messageDiv').innerText = "";
var cel = document.getElementById('iapsMainAppiList'+i).cells[1];
cel.innerHTML = parseInt(cel.innerText) + '<a href="#" onclick="showErrorMessage(\''+message+'\')">错误消息</a>';
}
}

if(result == 0){
document.form1.submit();
}else{
alert('您刚填写的数据存在逻辑问题,请录入完整!');
}
}

function checkRowBatchQcc(rowindex){

var message = "";   // 错误信息
var parameters = "" ;   // 单行提交的参数
var messArr = new Array();   // 吧两个 数据 存入 数组中 

//对数据域进行校验


   
    //主卡版面
    var appiMcColorObj = document.getElementById("iapsMainAppiList["+rowindex+"].appiMcColor");
    if(appiMcColorObj.options.length != 1 && appiMcColorObj.value == ''){
    message += "请选择主卡版面;";
    appiMcColorObj.style.backgroundColor="#FF0000";
    appiMcColorObj.onclick = function(){
    appiMcColorObj.style.backgroundColor= "";
    };
    }
    parameters += "iapsMainAppi.appiMcColor=" + appiMcColorObj.value ;

    // 主键
    var appiAppIdObj = document.getElementById("iapsMainAppiList["+rowindex+"].appiAppId");
if(appiAppIdObj.value != ""){
parameters += "&iapsMainAppi.appiAppId=" + appiAppIdObj.value ;
}
   
  //姓
var appiMcFirstName=document.getElementById("iapsMainAppiList["+rowindex+"].appiMcFirstName");
if(validateNotNull(appiMcFirstName)  == 1){
message += "申请人姓不能为空;";
}
parameters += "&iapsMainAppi.appiMcFirstName=" + appiMcFirstName.value;

//名
var appiMcFamilyname=document.getElementById("iapsMainAppiList["+rowindex+"].appiMcFamilyname");
if(validateNotNull(appiMcFamilyname)  == 1){
message += "申请人名不能为空;";
}
parameters += "&iapsMainAppi.appiMcFamilyname=" + appiMcFamilyname.value;

//姓名拼音
var appiMcKnowAsName1=document.getElementById("iapsMainAppiList["+rowindex+"].appiMcKnowAsName1");
if(validateNotNull(appiMcKnowAsName1)  == 1){
message += "姓名拼音不能为空;";
}else{
var appiMcKnowAsName1Result = getBlankNumber(appiMcKnowAsName1);
if(appiMcKnowAsName1Result && '' != appiMcKnowAsName1Result){
message += appiMcKnowAsName1Result;
}
}
parameters += "&iapsMainAppi.appiMcKnowAsName1=" + appiMcKnowAsName1.value;

//生日
var appiMcDob=document.getElementById("iapsMainAppiList["+rowindex+"].appiMcDob");
if(validateNotNull(appiMcDob)  == 1){
message += "生日不能为空;";
}else{
if(!isDate(appiMcDob.value)){
message += "请录入正确的身份证号;";
}
}
parameters += "&iapsMainAppi.appiMcDob=" + appiMcDob.value;

//证件号码
var appiMcIdNumber = document.getElementById("iapsMainAppiList["+rowindex+"].appiMcIdNumber");
var appiMcIdType = document.getElementById("iapsMainAppiList["+rowindex+"].appiMcIdType");
if(validateNotNull(appiMcIdNumber)  == 1){
message += "证件号码不能为空;";
}else{
// var appiMcIdType = document.getElementById("iapsMainAppiList["+rowindex+"].appiMcIdType");
if(appiMcIdType == 1){
var appiMcIdNumberChecke = checkIdcard(appiMcIdNumber.value);
if('true' != appiMcIdNumberChecke){
message += appiMcIdNumberChecke + ";";
}
}
}
parameters += "&iapsMainAppi.appiMcIdNumber=" + appiMcIdNumber.value;
parameters += "&iapsMainAppi.appiMcIdType=" + appiMcIdType.value;

var appiMcValidEndDate = document.getElementById("iapsMainAppiList["+rowindex+"].appiMcValidEndDate");
var appiMcValidLongFlag = document.getElementById("iapsMainAppiList["+rowindex+"].appiMcValidLongFlag");
if(appiMcValidEndDate.value != ''){
if(!isDate(appiMcValidEndDate.value)){
message += '请录入正确的证件有效期截至日期;';
}
}else{
if(!appiMcValidLongFlag.checked){
message += '证件有效期截至日期和证件有效期长期标识两者必须有一项不为空;';
appiMcValidEndDate.style.backgroundColor="#FF0000";
appiMcValidEndDate.onclick = function(){
appiMcValidEndDate.style.backgroundColor= "";
    };
    appiMcValidLongFlag.style.backgroundColor="#FF0000";
    appiMcValidLongFlag.onclick = function(){
    appiMcValidLongFlag.style.backgroundColor= "";
    };
}
}
parameters += "&iapsMainAppi.appiMcValidEndDate=" + appiMcValidEndDate.value;
parameters += "&iapsMainAppi.appiMcValidLongFlag=" + appiMcValidLongFlag.value;

//国籍
var appiMcNationality=document.getElementById("iapsMainAppiList["+rowindex+"].appiMcNationality"); 
if(validateNotNull(appiMcNationality) == 1){
message += "国籍不能为空;";
}
parameters += "&iapsMainAppi.appiMcNationality=" + appiMcNationality.value;

//手机号
var appiMcMPhone=document.getElementById("iapsMainAppiList["+rowindex+"].appiMcMPhone");
if(validateNotNull(appiMcMPhone)  == 1){
message += "手机号不能为空;";
}
if(!isMobile(appiMcMPhone.value)){
message += "请录入正确的手机号;";
}
parameters += "&iapsMainAppi.appiMcMPhone=" + appiMcMPhone.value;

var appiMcEmployerName = document.getElementById("iapsMainAppiList["+rowindex+"].appiMcEmployerName");
if(validateNotNull(appiMcEmployerName)  == 1){
message += "单位名称不能为空;";
}else{
if(calELength(appiMcEmployerName.value) > 30){
message += "单位名称长度超过最大长度;";
}
}
parameters += "&iapsMainAppi.appiMcEmployerName=" + appiMcEmployerName.value;


//邮寄地址选择,1为寄往公司,则公司地址不能为空
var appiMcBillAddrInd = document.getElementById("iapsMainAppiList["+rowindex+"].appiMcBillAddrInd");
var appiMcEmplPostCode = document.getElementById("iapsMainAppiList["+rowindex+"].appiMcEmplPostCode");
var appiMcPostCode = document.getElementById("iapsMainAppiList["+rowindex+"].appiMcPostCode");
if('1' === appiMcBillAddrInd.value){
// var appiMcEmplPostCode = document.getElementById("iapsMainAppiList["+rowindex+"].appiMcEmplPostCode");
if(validateNotNull(appiMcEmplPostCode) == 1){
message += "公司邮编不能为空;";
}
if(!isPostalCode(appiMcEmplPostCode.value)){
message += "您选择邮寄地址为寄往公司,请录入正确的邮政编码;";
}
parameters += "&iapsMainAppi.appiMcEmplPostCode=" + appiMcEmplPostCode.value;

}else{
// var appiMcPostCode = document.getElementById("iapsMainAppiList["+rowindex+"].appiMcPostCode");
if(validateNotNull(appiMcPostCode) == 1){
message += "住宅邮编不能为空;";
}
if(!isPostalCode(appiMcPostCode.value)){
message += "请录入正确的邮政编码;";
}
parameters += "&iapsMainAppi.appiMcPostCode=" + appiMcPostCode.value;
}
parameters += "&iapsMainAppi.appiMcBillAddrInd=" + appiMcBillAddrInd.value;

var appiMcEmplAddrState = document.getElementById("iapsMainAppiList["+rowindex+"].appiMcEmplAddrState");
if(validateNotNull(appiMcEmplAddrState) == 1){
message += "单位地址(省/直辖市)不能为空;";
}else{
if(calELength(appiMcEmplAddrState.value) > 30){
message += "单位地址(省/直辖市)长度超过最大长度;";
}
}
parameters += "&iapsMainAppi.appiMcEmplAddrState=" + appiMcEmplAddrState.value;

var appiMcEmplAddrCity = document.getElementById("iapsMainAppiList["+rowindex+"].appiMcEmplAddrCity");
if(validateNotNull(appiMcEmplAddrCity) == 1){
message += "单位地址(市/区/县)不能为空;";
}else{
if(calELength(appiMcEmplAddrCity.value) > 30){
message += "单位地址(市/区/县)长度超过最大长度;";
}
}
parameters += "&iapsMainAppi.appiMcEmplAddrCity=" + appiMcEmplAddrCity.value;

var appiMcEmplAddr1 = document.getElementById("iapsMainAppiList["+rowindex+"].appiMcEmplAddr1");
if(validateNotNull(appiMcEmplAddr1) == 1){
message += "单位地址一不能为空;";
}else{
if(calELength(appiMcEmplAddr1.value) > 30){
message += "单位地址一长度超过最大长度;";
}
}
parameters += "&iapsMainAppi.appiMcEmplAddr1=" + appiMcEmplAddr1.value;

var appiMcEmplAddr2 = document.getElementById("iapsMainAppiList["+rowindex+"].appiMcEmplAddr2");
//if(validateNotNull(appiMcEmplAddr2) == 1){
// message += "单位地址二不能为空;";
//}else{
if(calELength(appiMcEmplAddr2.value) > 30){
message += "单位地址二长度超过最大长度;";
}
//}
parameters += "&iapsMainAppi.appiMcEmplAddr2=" + appiMcEmplAddr2.value;

var appiMcEmplAddr3 = document.getElementById("iapsMainAppiList["+rowindex+"].appiMcEmplAddr3");
//if(validateNotNull(appiMcEmplAddr3) == 1){
// message += "单位地址三不能为空;";
//}else{
if(calELength(appiMcEmplAddr3.value) > 30){
message += "单位地址三长度超过最大长度;";
}
//}
parameters += "&iapsMainAppi.appiMcEmplAddr3=" + appiMcEmplAddr3.value;

var appiMcAddrState = document.getElementById("iapsMainAppiList["+rowindex+"].appiMcAddrState");
if(validateNotNull(appiMcAddrState) == 1){
message += "住宅地址(省/直辖市)不能为空;";
}else{
if(calELength(appiMcAddrState.value) > 30){
message += "住宅地址(省/直辖市)长度超过最大长度;";
}
}
parameters += "&iapsMainAppi.appiMcAddrState=" + appiMcAddrState.value;

var appiMcAddrCity = document.getElementById("iapsMainAppiList["+rowindex+"].appiMcAddrCity");
if(validateNotNull(appiMcAddrCity) == 1){
message += "住宅地址(市/区/县)不能为空;";
}else{
if(calELength(appiMcAddrCity.value) > 30){
message += "住宅地址(市/区/县)长度超过最大长度;";
}
}
parameters += "&iapsMainAppi.appiMcAddrCity=" + appiMcAddrCity.value;

var appiMcAddr1 = document.getElementById("iapsMainAppiList["+rowindex+"].appiMcAddr1");
if(validateNotNull(appiMcAddr1) == 1){
message += "住宅地址一不能为空;";
}else{
if(calELength(appiMcAddr1.value) > 30){
message += "住宅地址一长度超过最大长度;";
}
}
parameters += "&iapsMainAppi.appiMcAddr1=" + appiMcAddr1.value;

var appiMcAddr2 = document.getElementById("iapsMainAppiList["+rowindex+"].appiMcAddr2");
//if(validateNotNull(appiMcAddr2) == 1){
// message += "住宅地址二不能为空;";
//}else{
if(calELength(appiMcAddr2.value) > 30){
message += "住宅地址二长度超过最大长度;";
}
//}
parameters += "&iapsMainAppi.appiMcAddr2=" + appiMcAddr2.value;

var appiMcAddr3 = document.getElementById("iapsMainAppiList["+rowindex+"].appiMcAddr3");
//if(validateNotNull(appiMcAddr2) == 1){
// message += "住宅地址三不能为空;";
//}else{
if(calELength(appiMcAddr3.value) > 30){
message += "住宅地址三长度超过最大长度;";
}
//}
parameters += "&iapsMainAppi.appiMcAddr3=" + appiMcAddr3.value;

var appiMcMotherName = document.getElementById("iapsMainAppiList["+rowindex+"].appiMcMotherName");
if(validateNotNull(appiMcMotherName) == 1){
message += "母亲姓氏不能为空;";
}
parameters += "&iapsMainAppi.appiMcMotherName=" + appiMcMotherName.value;

//联系人与申请人关系
var appiMcContactRelship = document.getElementById("iapsMainAppiList["+rowindex+"].appiMcContactRelship");
if(validateNotNull(appiMcContactRelship) == 1){
message += "请选择联系人与申请人关系;";
}
parameters += "&iapsMainAppi.appiMcContactRelship=" + appiMcContactRelship.value;

//判断是否准贷卡
var appiProdCatCode = document.getElementById("iapsMainAppiList["+rowindex+"].appiProdCatCode");
if(appiProdCatCode.options[appiProdCatCode.selectedIndex].cardTypeFlag == 1 && document.getElementById("iapsMainAppiList["+rowindex+"].appiMcConsumeCity").value == ''){
message += "您选择的产品类型为准贷卡,请选择长城信用卡主卡所在地;"
}
parameters += "&iapsMainAppi.appiProdCatCode=" + appiProdCatCode.value;

//BH号
var appiBankinfoBh=document.getElementById("iapsMainAppiList["+rowindex+"].appiBankinfoBh");
if(validateNotNull(appiBankinfoBh) == 1){
message += "请填写BH号;";
}
parameters += "&iapsMainAppi.appiBankinfoBh=" + appiBankinfoBh.value;

//验证淘宝卡
// var appiProdCatCode = document.getElementById("iapsMainAppiList["+rowindex+"].appiProdCatCode");
var appiMcAlipayAccountType = document.getElementById("iapsMainAppiList["+rowindex+"].appiMcAlipayAccountType");
var appiMcEmailAddr = document.getElementById("iapsMainAppiList["+rowindex+"].appiMcEmailAddr");
if('58' == appiProdCatCode.value || '129' == appiProdCatCode.value){
// var appiMcAlipayAccountType = document.getElementById("iapsMainAppiList["+rowindex+"].appiMcAlipayAccountType");
if('' == appiMcAlipayAccountType.value){
message += "您选择的产品类型为淘宝卡,请选择淘宝卡账户类型;";
}else if('4000' == appiMcAlipayAccountType.value){
// var appiMcEmailAddr = document.getElementById("iapsMainAppiList["+rowindex+"].appiMcEmailAddr");
if(validateNotNull(appiMcEmailAddr) == 1){
message += "您选择的淘宝卡账户类型为4000电子邮箱,电子邮箱不能为空;";
}else{
if(!isEmail(appiMcEmailAddr.value)){
message += "您选择的淘宝卡账户类型为4000电子邮箱,请填写正确的电子邮箱地址;";
}
}
}
}
parameters += "&iapsMainAppi.appiMcAlipayAccountType=" + appiMcAlipayAccountType.value;
parameters += "&iapsMainAppi.appiMcEmailAddr=" + appiMcEmailAddr.value;

// 称谓
    var appiMcTitleObj = document.getElementById("iapsMainAppiList["+rowindex+"].appiMcTitle");
    parameters += "&iapsMainAppi.appiMcTitle=" + appiMcTitleObj.value;

    // 第二印花名   appiMcKnowAsName2
    var appiMcKnowAsName2Obj = document.getElementById("iapsMainAppiList["+rowindex+"].appiMcKnowAsName2");
    parameters += "&iapsMainAppi.appiMcKnowAsName2=" + appiMcKnowAsName2Obj.value;

    // 联系人姓名 appiMcContactName
    var appiMcContactNameObj = document.getElementById("iapsMainAppiList["+rowindex+"].appiMcContactName");
    parameters += "&iapsMainAppi.appiMcContactName=" + appiMcContactNameObj.value;

    // 联系人电话 appiMcContactMPhone
    var appiMcContactMPhoneObj = document.getElementById("iapsMainAppiList["+rowindex+"].appiMcContactMPhone");
    parameters += "&iapsMainAppi.appiMcContactMPhone=" + appiMcContactMPhoneObj.value;

    // 联系人单位 appiMcContactEmployer
    var appiMcContactEmployerObj = document.getElementById("iapsMainAppiList["+rowindex+"].appiMcContactEmployer");
    parameters += "&iapsMainAppi.appiMcContactEmployer=" + appiMcContactEmployerObj.value;
   
    // 长城信用卡主卡所在地 appiMcConsumeCity
    var appiMcConsumeCityObj = document.getElementById("iapsMainAppiList["+rowindex+"].appiMcConsumeCity");
    parameters += "&iapsMainAppi.appiMcConsumeCity=" + appiMcConsumeCityObj.value;

    // 免年费类型FW appiBankinfoFeeType
    var appiBankinfoFeeTypeObj = document.getElementById("iapsMainAppiList["+rowindex+"].appiBankinfoFeeType");
    parameters += "&iapsMainAppi.appiBankinfoFeeType=" + appiBankinfoFeeTypeObj.value;

    // 银行专用信息推荐员工标识IN appiBankinfoPccIn
    var appiBankinfoPccInObj = document.getElementById("iapsMainAppiList["+rowindex+"].appiBankinfoPccIn");
    parameters += "&iapsMainAppi.appiBankinfoPccIn=" + appiBankinfoPccInObj.value;

    // POS验密参数 appiMcConsume
    var appiMcConsumeObj = document.getElementById("iapsMainAppiList["+rowindex+"].appiMcConsume");
    parameters += "&iapsMainAppi.appiMcConsume=" + appiMcConsumeObj.value;

    // 毕业年份 appiMcAssetValue
    var appiMcAssetValueObj = document.getElementById("iapsMainAppiList["+rowindex+"].appiMcAssetValue");
    parameters += "&iapsMainAppi.appiMcAssetValue=" + appiMcAssetValueObj.value;

    // 单位编号appiMcOtherCard2Bank
    var appiMcOtherCard2BankObj = document.getElementById("iapsMainAppiList["+rowindex+"].appiMcOtherCard2Bank");
    parameters += "&iapsMainAppi.appiMcOtherCard2Bank=" + appiMcOtherCard2BankObj.value;

    // 把行号作为参数 传递过去  用来 追加主键 appi_id 的时候用
    // parameters += "&rowindex=" + rowindex ;

    // var appiBatchfile = document.getElementById("appiBatchfile").vlaue;
    // parameters += "&appiBatchfile=" + appiBatchfile ;
   
if(message == ""){
// appiMcFirstName.readOnly = true ;
appiMcColorObj.disabled = true ;
appiMcFirstName.disabled = true ;
appiMcFamilyname.disabled = true ;
appiMcKnowAsName1.disabled = true ;
appiMcDob.disabled = true ;
appiMcIdNumber.disabled = true ;
appiMcIdType.disabled = true ;
appiMcValidEndDate.disabled = true ;
appiMcValidLongFlag.disabled = true ;
appiMcNationality.disabled = true ;
appiMcMPhone.disabled = true ;
appiMcEmployerName.disabled = true ;
appiMcBillAddrInd.disabled = true ;
appiMcEmplPostCode.disabled = true ;
appiMcPostCode.disabled = true ;
appiMcEmplAddrState.disabled = true ;
appiMcEmplAddrCity.disabled = true ;
appiMcEmplAddr1.disabled = true ;
appiMcEmplAddr2.disabled = true ;
appiMcEmplAddr3.disabled = true ;
appiMcAddrState.disabled = true ;
appiMcAddrCity.disabled = true ;
appiMcAddr1.disabled = true ;
appiMcAddr2.disabled = true ;
appiMcAddr3.disabled = true ;
appiMcMotherName.disabled = true ;
appiMcContactRelship.disabled = true ;
appiProdCatCode.disabled = true ;
appiBankinfoBh.disabled = true ;
appiProdCatCode.disabled = true ;
appiMcAlipayAccountType.disabled = true ;
appiMcEmailAddr.disabled = true ;

appiMcTitleObj.disabled = true ;
appiMcKnowAsName2Obj.disabled = true ;
appiMcContactNameObj.disabled = true ;
appiMcContactMPhoneObj.disabled = true ;
appiMcContactEmployerObj.disabled = true ;
appiMcConsumeCityObj.disabled = true ;
appiBankinfoFeeTypeObj.disabled = true ;
appiBankinfoPccInObj.disabled = true ;
appiMcConsumeObj.disabled = true ;
appiMcAssetValueObj.disabled = true ;
appiMcOtherCard2BankObj.disabled = true ;

}

// 先判断message 是否是“” 是“” 说明数据规格正确  然后存入 array 中
if(message == ""){
// 把手机号码存入 数组中
phoneArr.push(appiMcMPhone.value);
}
// message  为空 条件 成立 拼接 参数 
if(message != ""){
parameters = "";
}
messArr.push(message);
messArr.push(parameters);
// messArr.push(rowindex);
messArr.push("iapsMainAppiList["+rowindex+"].appiAppId");
//alert("message:" + message);
//alert("parameters:" + parameters);

return messArr ;
}
function validateNotNull(eleObj)
{
  if(eleObj.value==""||eleObj.value=="不能为空")
  {
     eleObj.style.backgroundColor="#FF0000";
     eleObj.value="不能为空";
return 1;
  }
  else
  {
  // alert(eleObj.value);
    eleObj.style.backgroundColor="";
  }
  return 0;
}

//验证select标签
function validateSelect(eleObj){
if('' === eleObj.value){
eleObj.style.backgroundColor="#FF0000";
return 1;
}
return 0;
}

function aa(eleObj){
if(eleObj.value=="不能为空" || '' === eleObj.value){
   eleObj.value="";
eleObj.style.backgroundColor="";
   eleObj.focus();
   }
}

function validateEmail( eleObj ){
if(!isEmail(eleObj.value)){
eleObj.style.backgroundColor="#FF0000";
return 1;
}
return 0;
}

function isEmail(strValue){
// Email 必须是 x@a.b.c.d 等格式 或者为空
if( isEmpty( strValue ) )
return true;
var pattern = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/;
return checkExp( pattern, strValue );
}

function isEmpty( strValue ){
if( "" === strValue)
return true;
return false;
}

// 使用正则表达式,检测 s 是否满足模式 re
function checkExp( re, s ){
return re.test( s );
}

//根据证件号码自动设置生日
function setAppiMcDob(obj,index){
var appiMcIdNumberValue = obj.value;
if((document.getElementById('iapsMainAppiList['+index+'].appiMcIdType').value == '1') && appiMcIdNumberValue != ''){
/*
if(checkExp(/^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{4}$/gi , appiMcIdNumberValue)){
var appiMcDobValue = appiMcIdNumberValue.substring(6,10) + '-' + appiMcIdNumberValue.substring(10,12) + '-' + appiMcIdNumberValue.substring(12,14);
document.getElementById('iapsMainAppiList['+index+'].appiMcDob').value = appiMcDobValue;
}else{
alert('请录入正确的身份证号!');
}
*/
var checkIdcardResult = checkIdcard(appiMcIdNumberValue)
if('true' == checkIdcardResult){
var appiMcDobValue = appiMcIdNumberValue.substring(6,10) + '-' + appiMcIdNumberValue.substring(10,12) + '-' + appiMcIdNumberValue.substring(12,14);
document.getElementById('iapsMainAppiList['+index+'].appiMcDob').value = appiMcDobValue;
}else{
alert(checkIdcardResult);
}
}
}

function checkPerName(obj)
{
      var partten = /^[\u4e00-\u9fa5A-Za-z]*$/;
      var name = obj.value;
      if(trimSpace(name) != "")
      {
      if(!partten.test(trimSpace(name)))
      {
          alert("请输入汉字或字母");
          obj.focus();
          return false;
      }
     }
     obj.value = obj.value.trim();
}

function isDate(value){
var pattern =/^((\d{2}(([02468][048])|([13579][26]))[\-\/\s]?((((0?[13578])|(1[02]))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\-\/\s]?((0?[1-9])|([1-2][0-9])))))|(\d{2}(([02468][1235679])|([13579][01345789]))[\-\/\s]?((((0?[13578])|(1[02]))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\-\/\s]?((0?[1-9])|(1[0-9])|(2[0-8]))))))(\s(((0?[0-9])|([1-2][0-3]))\:([0-5]?[0-9])((\s)|(\:([0-5]?[0-9])))))?$/;
if(value!=""){
if(!pattern.exec(value)){
return false;
}
return true;
}
}

function checkIdcard(idcard){
var Errors=new Array(
"true",
"身份证号码位数有误,请输入15或18位身份证号码",
"身份证号码出生日期超出范围或含有非法字符!",
"身份证号码校验错误!",
"身份证地区非法!"
);
var area={11:"北京",12:"天津",13:"河北",14:"山西",15:"内蒙古",21:"辽宁",22:"吉林",23:"黑龙江",31:"上海",32:"江苏",33:"浙江",34:"安徽",35:"福建",36:"江西",37:"山东",41:"河南",42:"湖北",43:"湖南",44:"广东",45:"广西",46:"海南",50:"重庆",51:"四川",52:"贵州",53:"云南",54:"西藏",61:"陕西",62:"甘肃",63:"青海",64:"宁夏",65:"新疆",71:"台湾",81:"香港",82:"澳门",91:"国外"} 
var idcard,Y,JYM;
var S,M;
var idcard_array = new Array();
idcard_array = idcard.split("");
//地区检验
if(area[parseInt(idcard.substr(0,2))]==null)
return Errors[4];
//身份号码位数及格式检验
switch(idcard.length){
case 15:
if ( (parseInt(idcard.substr(6,2))+1900) % 4 == 0 || ((parseInt(idcard.substr(6,2))+1900) % 100 == 0 && (parseInt(idcard.substr(6,2))+1900) % 4 == 0 )){
ereg=/^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}$/;//测试出生日期的合法性
} else {
ereg=/^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}$/;//测试出生日期的合法性
}
if(ereg.test(idcard))
return Errors[0];
else
return Errors[2];
break;
case 18:
//18位身份号码检测
//出生日期的合法性检查 
//闰年月日:((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))
//平年月日:((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))
if ( parseInt(idcard.substr(6,4)) % 4 == 0 || (parseInt(idcard.substr(6,4)) % 100 == 0 && parseInt(idcard.substr(6,4))%4 == 0 )){
ereg=/^[1-9][0-9]{5}19[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}[0-9Xx]$/;//闰年出生日期的合法性正则表达式
} else {
ereg=/^[1-9][0-9]{5}19[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}[0-9Xx]$/;//平年出生日期的合法性正则表达式
}
if(ereg.test(idcard)){//测试出生日期的合法性
//计算校验位
S = (parseInt(idcard_array[0]) + parseInt(idcard_array[10])) * 7
+ (parseInt(idcard_array[1]) + parseInt(idcard_array[11])) * 9
+ (parseInt(idcard_array[2]) + parseInt(idcard_array[12])) * 10
+ (parseInt(idcard_array[3]) + parseInt(idcard_array[13])) * 5
+ (parseInt(idcard_array[4]) + parseInt(idcard_array[14])) * 8
+ (parseInt(idcard_array[5]) + parseInt(idcard_array[15])) * 4
+ (parseInt(idcard_array[6]) + parseInt(idcard_array[16])) * 2
+ parseInt(idcard_array[7]) * 1 
+ parseInt(idcard_array[8]) * 6
+ parseInt(idcard_array[9]) * 3 ;
Y = S % 11;
M = "F";
JYM = "10X98765432";
M = JYM.substr(Y,1);//判断校验位
if(M == idcard_array[17])
return Errors[0]; //检测ID的校验位
else
return Errors[3];
} else
return Errors[2];
break;
default:
return Errors[1];
break;
}
}
function isMobile(value){
var reg0 = /^1[3,5,8]\d{9}$/;
if (reg0.test(value))
return true;
return false;
}
function isTelphone(value) {
var pattern=/^(\d{7,8})$/;
if(pattern.exec(s))
return true;
return false;
}

function isPostalCode(value){
var pattern =/^[0-9]{6}$/;
if(pattern.exec(value))
return true;
return false;
}

function changeAppiMcIdType(val, rowIndex){
var appiMcDob = document.getElementById('iapsMainAppiList['+rowIndex+'].appiMcDob');
if(1 == val){
appiMcDob.readOnly = true;
appiMcDob.style.cursor = "pointer";
}else{
appiMcDob.readOnly = false;
appiMcDob.style.cursor = "default";
}
}

function getBlankNumber(obj){
var str = document.getElementById(obj.id).value;
if(escape(str).indexOf("%u") > 0){
return "姓名拼音只能输入英文字符;";
}
if(str!=""){
var temp = "";
whitespace = ' \n\r\t\f\x0b\xa0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u3000'; 
for (var i = 0,len = str.length; i < len; i++) {  
if (whitespace.indexOf(str.charAt(i)) === -1) {  
str = str.substring(i);  
break;  
}  
}  
for (i = str.length - 1; i >= 0; i--) {  
    if (whitespace.indexOf(str.charAt(i)) === -1) {  
str = str.substring(0, i + 1);  
      break;  
    }  
}  
var s = str.length;
for (var i = 0,len = str.length; i < len; i++) {  
if (whitespace.indexOf(str.charAt(i)) === -1) {  
     temp=temp+str.charAt(i);
    }  
}  
var e = temp.length;
if((s-e)!=1){
return "请在姓和名之间以空格隔开;";
}else{
obj.value = str;
obj.value = obj.value.toUpperCase();
}
}
}
</script>
</body>
</html>
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics