农行网银后台采用的Javascript函数,比如
金额的大小写转换;
javascript打印;
导出数据到Excel;
数据有效性的验证
很强很实用:)
var beginDate = new Date(); /* 网银二期公用script校验函数 ** 建立日期:2001-12-20 */ var numIndex = 0; function checkClick() { if (numIndex != 0) { return true; } numIndex = 1; return false; } function isClicked() { return numIndex > 0; } //**************公共客户系统关闭,取消按钮实现************ function pageClose_Common(path) { //alert(); window.location.href = path + "DefaultPerson.aspx"; } //**************个人客户系统关闭,取消按钮实现************ function pageClose_Person(path) { //**************当弹出页面时,关闭弹出页面************ if(typeof(window.opener)!="undefined") { window.close(); return; } //******************************************************** window.location.href = path + "DefaultPerson.aspx"; } //**************企业关闭,取消按钮实现************ function pageClose_Enterprise(path) { window.location.href = path + "DefaultPerson.aspx"; } //**************CIF系统关闭,取消按钮实现************ function pageClose_Cif(path) { window.location.href = path + "DefaultPerson.aspx"; } //去掉空格 function javaTrim(string) { var length1, i, j; var string1 = ""; length1 = string.length; for (i = 0 ; i < length1 ; i++) { //除去左边空格 if(string.charAt(i) != " ") {//除去左边空格后 for (j = i ; j < length1 ; j++) string1 = string1 + string.charAt(j); break; } } length1 = string1.length; string = string1; string1 = ""; for (i = length1 - 1 ; i >= 0 ; i--) { //除去右边空格 if(string.charAt(i) != " ") {//除去右边空格后 for (j = 0 ; j <= i ; j++) string1 = string1 + string.charAt(j); break; } } string = string1; return(string) } // 检查Email是否合法 // 返回true为正确 function isEmail(string) { var string1=""; var len=0; len=string1.length; string1=javaTrim(string); if(string1.length!=0) { if (string1.indexOf("@",1)==-1||string1.indexOf(".",1)==-1||string1.length<7) { alert("电子邮箱的格式不对,请重新填写!"); return false; } if (string1.charAt(len-1)=="."||string1.charAt(len-1)=="@") { alert("电子邮箱的格式不对,请重新填写!"); return false; } } else { alert("电子邮箱不能为空,请填写!"); return false; } return true; } //验证邮政编码 function isPostCode(str) { if (str.length != 6) { alert("邮编输入长度错误"); return false; } if (!isNumber(str)) { alert("邮编只能为数字"); return false; } return true; } // 检查是否闰年 function isLeapYear(year) { if(year%4==0 && year%100!=0 || year % 400 == 0) return true; return false; } // 判断日期是否合法 格式 yyyymmdd function isDate(strDate) { if (strDate.length != 8) { alert("日期长度错误"); return false; } if (!isNumber(strDate)) { alert("日期输入错误"); return false; } var year = parseInt(strDate.substring(0,4),10); var mm = parseInt(strDate.substring(4,6),10); var dd = parseInt(strDate.substring(6,8),10); var monthDates = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; if (isLeapYear(strDate)) monthDates[1] = 29; if (mm > 12 || mm < 1) { alert("月份应在1-12之间"); return false; } if (dd > monthDates[mm-1] || dd < 1) { alert("日期输入错误"); return false; } return true; } //选中某个数据域 function makeFocus(txtObject) { txtObject.focus(); txtObject.select(); } //判断数值,必须为纯数字 function isNumber(string) { var length1 , i , j; var string1 = javaTrim(string); length1 = string1.length; if (length1 == 0) { return(false); } for (i = 0 ; i < length1 ; i++) { //判断每位数字 if(isNaN(parseInt(string.charAt(i),10))) { return(false); } } return (true); } //判断数值,是否为浮点数 function isMoney(string) { var length1 , i , j, k, flag = 0; var string1=""; string1 = javaTrim(string); k = length1 = string1.length; if ((string1 == "0.00") || (string1 == "0.0") || (string1 == "0.") || (string1 == "0")) { alert("错误!金额不能为0,请重新填写。"); return (false); } if (length1 == 0) { alert( "不能输入空字符"); return(false); } if (string1.charAt(0)=="0" ) { if (length1 == 1) { alert("金额不能为0,请重新填写!"); return(false); } else { if (!(string1.charAt(1)==".")) { alert("金额首位不能为0,请重新填写!"); return(false); } } } j=0; for (i = 0 ; i < length1 ; i++) { //判断每位数字 if(isNaN(parseInt(string1.charAt(i),10))) { if(string1.charAt(i) != ".") { alert( "请输入数值型数据!"); return(false); } else { j++; if(length1 - i > 3 ) { alert("小数点后只能有两位!"); return(false); } } if (flag == 0) { k = i; flag = 1; } } } if (k > 12) { alert("金额长度超过限额"); return false; } if(j > 1) { alert( "小数点只能有一个!"); return false; } return true; } function isPassword(passwd) { if (passwd.length < 4) { alert("密码长度至少为四位"); return false; } if (passwd.length > 6) { alert("密码长度不能大于六位"); return false; } if (!isNumber(passwd)) { alert("密码只能为数字"); return false; } return true; } function disable_Button(name) { name.disabled=1 } function reload(name1) { name1.reset(); } //hyh020109从groutpublic中拷贝过来 function selectAll() { setAllChecked(document, true); } function resetAll() { setAllChecked(document,false); } function setAllChecked(element, chk) { var chks = element.getElementsByTagName("input"); for (var i = 0; i < chks.length; i++) { if (chks(i).type == "checkbox") { chks(i).checked = chk; } } } //判断开户行是否为除农行外的其他银行 function checkOtherBank(bnkType){ if (bnkType.substring(0,3)=="999"){ return true; } return false; } //判断该分行是否是上收行 function checkBankFlag(bnkType) { var banks = new Array(); banks[banks.length] = "30005"; //总行营业部 banks[banks.length] = "30949"; //北京分行 banks[banks.length] = "39794"; //天津分行 banks[banks.length] = "30414"; //河北分行 banks[banks.length] = "12345"; //山西分行 banks[banks.length] = "31520"; //内蒙古分行 banks[banks.length] = "31900"; //辽宁分行 banks[banks.length] = "32224"; //吉林分行 banks[banks.length] = "32575"; //黑龙江分行 banks[banks.length] = "30399"; //上海分行 banks[banks.length] = "34450"; //江苏分行 banks[banks.length] = "35300"; //浙江分行 banks[banks.length] = "34905"; //安徽分行 banks[banks.length] = "35550"; //福建分行 banks[banks.length] = "37430"; //江西分行 banks[banks.length] = "34150"; //山东分行 banks[banks.length] = "36260"; //河南分行 banks[banks.length] = "36630"; //湖北分行 banks[banks.length] = "37000"; //湖南分行 banks[banks.length] = "24400"; //广东分行 banks[banks.length] = "38066"; //广西分行 banks[banks.length] = "37521"; //海南分行 banks[banks.length] = "38648"; //四川分行 banks[banks.length] = "38880"; //贵州分行 banks[banks.length] = "39366"; //云南分行 banks[banks.length] = "39601"; //西藏分行 banks[banks.length] = "38200"; //重庆分行 banks[banks.length] = "33017"; //陕西分行 banks[banks.length] = "33250"; //甘肃分行 banks[banks.length] = "33485"; //青海分行 banks[banks.length] = "33350"; //宁夏分行 banks[banks.length] = "33799"; //新疆分行 //新疆兵团已并入新疆分行 banks[banks.length] = "33796"; //兵团分行 banks[banks.length] = "32706"; //深圳分行 banks[banks.length] = "35261"; //宁波分行 banks[banks.length] = "35525"; //厦门分行 banks[banks.length] = "34160"; //青岛分行 banks[banks.length] = "31660"; //大连分行 for (i=0;i<banks.length;i++){ if (bnkType == banks[i]){ return "1"; } } return "0"; } //判断分行是否已开通转账业务 function checkOwnBank(bnkType) { var banks = new Array(); banks[banks.length] = "30005"; //总行营业部 banks[banks.length] = "30949"; //北京分行 banks[banks.length] = "39794"; //天津分行 banks[banks.length] = "30414"; //河北分行 banks[banks.length] = "12345"; //山西分行 banks[banks.length] = "31520"; //内蒙古分行 banks[banks.length] = "31900"; //辽宁分行 banks[banks.length] = "32224"; //吉林分行 banks[banks.length] = "32575"; //黑龙江分行 banks[banks.length] = "30399"; //上海分行 banks[banks.length] = "34450"; //江苏分行 banks[banks.length] = "35300"; //浙江分行 banks[banks.length] = "34905"; //安徽分行 banks[banks.length] = "35550"; //福建分行 banks[banks.length] = "37430"; //江西分行 banks[banks.length] = "34150"; //山东分行 banks[banks.length] = "36260"; //河南分行 banks[banks.length] = "36630"; //湖北分行 banks[banks.length] = "37000"; //湖南分行 banks[banks.length] = "24400"; //广东分行 banks[banks.length] = "38066"; //广西分行 banks[banks.length] = "37521"; //海南分行 banks[banks.length] = "38648"; //四川分行 banks[banks.length] = "38880"; //贵州分行 banks[banks.length] = "39366"; //云南分行 banks[banks.length] = "39601"; //西藏分行 banks[banks.length] = "38200"; //重庆分行 banks[banks.length] = "33017"; //陕西分行 banks[banks.length] = "33250"; //甘肃分行 banks[banks.length] = "33485"; //青海分行 banks[banks.length] = "33350"; //宁夏分行 banks[banks.length] = "33799"; //新疆分行 //新疆兵团已并入新疆分行 //banks[banks.length] = "33796"; //兵团分行 banks[banks.length] = "32706"; //深圳分行 banks[banks.length] = "35261"; //宁波分行 banks[banks.length] = "35525"; //厦门分行 banks[banks.length] = "34160"; //青岛分行 banks[banks.length] = "31660"; //大连分行 for (i=0;i<banks.length;i++){ if (bnkType == banks[i]){ return true; } } return false; } //判断分行是否已开通验证账户名业务 function checkProBank(proCode) { var banks = new Array(); banks["10"] = "30005"; //总行营业部 banks["11"] = "30949"; //北京分行 banks["12"] = "39794"; //天津分行 banks["13"] = "30414"; //河北分行 banks["14"] = "12345"; //山西分行 banks["15"] = "31520"; //内蒙古分行 banks["21"] = "31900"; //辽宁分行 banks["22"] = "32224"; //吉林分行 banks["23"] = "32575"; //黑龙江分行 banks["31"] = "30399"; //上海分行 banks["32"] = "34450"; //江苏分行 banks["33"] = "35300"; //浙江分行 banks["34"] = "34905"; //安徽分行 banks["35"] = "35550"; //福建分行 banks["36"] = "37430"; //江西分行 banks["37"] = "34150"; //山东分行 banks["41"] = "36260"; //河南分行 banks["42"] = "36630"; //湖北分行 banks["43"] = "37000"; //湖南分行 banks["44"] = "24400"; //广东分行 banks["45"] = "38066"; //广西分行 banks["46"] = "37521"; //海南分行 banks["51"] = "38648"; //四川分行 banks["52"] = "38880"; //贵州分行 banks["53"] = "39366"; //云南分行 banks["54"] = "39601"; //西藏分行 banks["55"] = "38200"; //重庆分行 banks["61"] = "33017"; //陕西分行 banks["62"] = "33250"; //甘肃分行 banks["63"] = "33485"; //青海分行 banks["64"] = "33350"; //宁夏分行 banks["65"] = "33799"; //新疆分行 //新疆兵团已并入新疆分行 //banks["66"] = "33796"; //兵团分行 banks["81"] = "32706"; //深圳分行 banks["82"] = "35261"; //宁波分行 banks["83"] = "35525"; //厦门分行 banks["84"] = "34160"; //青岛分行 banks["85"] = "31660"; //大连分行 return banks[proCode]; } function getAreaByPrv(prv) { //初始化 var prvCode = new Array(); var areCode = new Array(); areCode[0] = '11'; //北京市分行 prvCode[0] = '11'; //北京市分行 areCode[1] = '12'; //天津市分行 prvCode[1] = '02'; //天津市分行 areCode[2] = '13'; //河北省分行 prvCode[2] = '50'; //河北省分行 areCode[3] = '14'; //山西省分行 prvCode[3] = '04'; //山西省分行 areCode[4] = '15'; //内蒙古自治区分行 prvCode[4] = '05'; //内蒙古自治区分行 areCode[5] = '21'; //辽宁省分行 prvCode[5] = '06'; //辽宁省分行 areCode[6] = '85'; //大连市分行 prvCode[6] = '34'; //大连市分行 areCode[7] = '22'; //吉林省分行 prvCode[7] = '07'; //吉林省分行 areCode[8] = '23'; //黑龙江省分行 prvCode[8] = '08'; //黑龙江省分行 areCode[9] = '31'; //上海市分行 //prvCode[9] = '09'; //上海市分行 prvCode[9] = '03'; //上海市分行 areCode[10] = '32'; //江苏省分行 prvCode[10] = '10'; //江苏省分行 areCode[11] = '33'; //浙江省分行 prvCode[11] = '19'; //浙江省分行 areCode[12] = '82'; //宁波市分行 prvCode[12] = '39'; //宁波市分行 areCode[13] = '34'; //安徽省分行 prvCode[13] = '12'; //安徽省分行 areCode[14] = '35'; //福建省分行 prvCode[14] = '13'; //福建省分行 areCode[15] = '83'; //厦门市分行 prvCode[15] = '40'; //厦门市分行 areCode[16] = '36'; //江西省分行 prvCode[16] = '14'; //江西省分行 areCode[17] = '37'; //山东省分行 prvCode[17] = '15'; //山东省分行 areCode[18] = '84'; //青岛市分行 prvCode[18] = '38'; //青岛市分行 areCode[19] = '41'; //河南省分行 prvCode[19] = '16'; //河南省分行 areCode[20] = '42'; //湖北省分行 prvCode[20] = '17'; //湖北省分行 areCode[21] = '43'; //湖南省分行 prvCode[21] = '18'; //湖南省分行 areCode[22] = '44'; //广东省分行 prvCode[22] = '44'; //广东省分行 areCode[23] = '81'; //深圳市分行 prvCode[23] = '41'; //深圳市分行 areCode[24] = '45'; //广西自治区分行 prvCode[24] = '20'; //广西自治区分行 areCode[25] = '46'; //海南省分行 prvCode[25] = '21'; //海南省分行 areCode[26] = '51'; //四川省分行 prvCode[26] = '22'; //四川省分行 areCode[27] = '52'; //贵州省分行 prvCode[27] = '23'; //贵州省分行 areCode[28] = '53'; //云南省分行 prvCode[28] = '24'; //云南省分行 areCode[29] = '54'; //西藏自治区分行 prvCode[29] = '25'; //西藏自治区分行 areCode[30] = '61'; //陕西省分行 prvCode[30] = '26'; //陕西省分行 areCode[31] = '62'; //甘肃省分行 prvCode[31] = '27'; //甘肃省分行 areCode[32] = '63'; //青海省分行 prvCode[32] = '28'; //青海省分行 areCode[33] = '64'; //宁夏自治区分行 prvCode[33] = '29'; //宁夏自治区分行 areCode[34] = '65'; //新疆自治区分行 prvCode[34] = '30'; //新疆自治区分行 areCode[35] = '55'; //重庆市分行 prvCode[35] = '31'; //重庆市分行 areCode[36] = '10'; //总行营业部 prvCode[36] = '81'; //总行营业部 for (i=0;i<prvCode.length;i++){ if (prv == prvCode[i]){ return areCode[i]; } } return "00"; } //通用打印 function commonprint(t1,t2,w,h){ var sarg=new Array(); var sdata=document.all.item(t2); sarg[0]=t1; sarg[1]=sdata.outerHTML; window.showModalDialog(top.ebankBasepath+"/print.aspx",sarg,"dialogWidth:"+w+"px;dialogHeight:"+h+"px;center:yes;help:no;status:no;resizable:yes"); return; } function exportexcelEx(arg1){ var oXL = new ActiveXObject("Excel.Application"); oXL.Visible = true; var oWB = oXL.Workbooks.Add(); var oSheet = oWB.ActiveSheet; var rlen = 0; var clen = 0; var div1=document.all.item(arg1); var rowBegin = new Array(); var colBegin = 1; for (var i=0; i<div1.getElementsByTagName("TABLE").length; i++) { var table = div1.getElementsByTagName("TABLE")[i]; var retArr = getTableRowsCols(table); rowBegin[i] = rlen + 1; rlen = rlen + retArr[0]; clen = clen + retArr[1]; } var flagTable=new Array(rlen); for(var i=0;i<rlen;i++){ flagTable[i]=new Array(clen); for(var j=0;j<clen;j++){ flagTable[i][j]=0; } } for (var i=0; i<div1.getElementsByTagName("TABLE").length; i++) { var table1 = div1.getElementsByTagName("TABLE")[i]; var c1=oSheet.Cells(rowBegin[i],colBegin); var c2=oSheet.Cells(rlen+rowBegin[i]-1,clen+colBegin-1); oSheet.Range(c1,c2).VerticalAlignment = -4108; oSheet.Range(c1,c2).HorizontalAlignment = -4108; exportTable(oSheet, flagTable, table1, rowBegin[i], colBegin); oSheet.Range(oSheet.Cells(rowBegin[i],colBegin),oSheet.Cells(rlen+rowBegin[i]-1,clen+colBegin-1)).EntireColumn.AutoFit(); } oXL.UserControl = true; oXL.Quit(); //oXL.UserControl = true; //oXL.Quit(); } //生成Excel文件 function exportexcel(arg1,arg2){ var oXL = new ActiveXObject("Excel.Application"); oXL.Visible = true; var oWB = oXL.Workbooks.Add(); var oSheet = oWB.ActiveSheet; var rlen = 0; var clen = 0; var div1=document.all.item(arg1); var rowBegin = new Array(); var colBegin = 1; for (var i=0; i<div1.all.item(arg2).length; i++) { var table = div1.all.item(arg2)[i]; var retArr = getTableRowsCols(table); rowBegin[i] = rlen + 1; rlen = rlen + retArr[0]; clen = clen + retArr[1]; } var flagTable=new Array(rlen); for(var i=0;i<rlen;i++){ flagTable[i]=new Array(clen); for(var j=0;j<clen;j++){ flagTable[i][j]=0; } } for (var i=0; i<div1.all.item(arg2).length; i++) { var table1 = div1.all.item(arg2)[i]; var c1=oSheet.Cells(rowBegin[i],colBegin); var c2=oSheet.Cells(rlen+rowBegin[i]-1,clen+colBegin-1); oSheet.Range(c1,c2).VerticalAlignment = -4108; oSheet.Range(c1,c2).HorizontalAlignment = -4108; exportTable(oSheet, flagTable, table1, rowBegin[i], colBegin); oSheet.Range(oSheet.Cells(rowBegin[i],colBegin),oSheet.Cells(rlen+rowBegin[i]-1,clen+colBegin-1)).EntireColumn.AutoFit(); } oXL.UserControl = true; oXL.Quit(); //oXL.UserControl = true; //oXL.Quit(); } //返回当前表格的行数和列数 //参数:objTable, 表格对象 //返回:retArr, retArr[0], 行数;retArr[1], 列数 function getTableRowsCols(objTable) { var rowCnt=0, colCnt=0; for (var i=0; i<objTable.rows.length; i++) { var row = objTable.rows[i]; //当前行 var rowRows=1, rowCols=0; //当前行的初始行数和列数 for (var j=0; j<row.cells.length; j++) { var cell = row.cells[j]; //当前单元格 if (cell.firstChild !=null && cell.firstChild.tagName == "TABLE") { var inRetArr = getTableRowsCols(cell.firstChild); rowCols +=inRetArr [1]; rowRows = rowRows<inRetArr[0] ? inRetArr[0] : rowRows; } else { //不是表格 rowCols += parseInt(cell.colSpan); rowRows = rowRows<parseInt(cell.rowSpan) ? parseInt(cell.rowSpan) : rowRows; } } colCnt = colCnt<rowCols ? rowCols : colCnt; rowCnt += rowRows; } var retArr = new Array(); retArr[0] = rowCnt; retArr[1] = colCnt; return retArr; } //导出表格 function exportTable(oSheet, flagTable, objTable, rowBegin, colBegin){ var flagRow=0, flagCol=0; //跟踪当前的表示表中的相对位置 for(var i=0; i<objTable.rows.length; i++) { var row = objTable.rows[i]; //当前行 flagCol = 0; var subTableRows = 1; //当前行若有表格,则记录其中最大的行数 for (var j=0; j<row.cells.length; j++) { while (flagTable[rowBegin-1+flagRow][colBegin-1+flagCol]==1) { flagCol++; } var cell=row.cells[j]; //当前单元格 if (cell.firstChild !=null && cell.firstChild.tagName == "TABLE") { var retArrRows = getTableRowsCols(cell.firstChild)[0]; subTableRows = subTableRows<retArrRows ? retArrRows : subTableRows; exportTable(oSheet, flagTable, cell.firstChild, rowBegin+flagRow, colBegin+flagCol); } else { oSheet.Cells(rowBegin+flagRow, colBegin+flagCol).Font.Bold=1; var rs=parseInt(cell.rowSpan); var cs=parseInt(cell.colSpan); oSheet.Cells(rowBegin+flagRow, colBegin+flagCol).NumberFormatLocal="@"; oSheet.Cells(rowBegin+flagRow, colBegin+flagCol).Value = cell.innerText; oSheet.Range(oSheet.Cells(rowBegin+flagRow, colBegin+flagCol),oSheet.Cells(rowBegin+flagRow+rs-1,colBegin+flagCol+cs-1)).MergeCells = 1; //填写当前单元格在标志表格中的标志 for(var k=0; k<rs; k++) { for(var l=0; l<cs; l++) { flagTable[rowBegin-1+flagRow+k][colBegin-1+flagCol+l]=1; } } } flagCol =flagCol + cs - 1; //加速标志表格的列的移动,因为当前表格已经标识了cs个标志单元 } flagRow += subTableRows; } } //hyh020109 function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; } function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } function MM_findObj(n, d) { //v4.0 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && document.getElementById) x=document.getElementById(n); return x; } function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } //左侧菜单高度初始化函数 function doManuHeight(){ iFrame1.height = eval(screen.height - 215); } function isCardNoValidate(cardNo) { var length1 = cardNo.length; var i, total=0; for (i=length1-2; i>=0; i=i-2) { if(parseInt(cardNo.charAt(i))>=5) { total=total+(parseInt(cardNo.charAt(i))*2)-9; } else { total=total+(parseInt(cardNo.charAt(i))*2); } } for (i=length1-3; i>=0; i=i-2) { total=total+parseInt(cardNo.charAt(i)); } var checkCode = (10 - total % 10) % 10; if (checkCode == parseInt(cardNo.charAt(length1-1))) { return true; } return false; } Date.prototype.format = function(format) //author: meizz { var o = { "M+" : this.getMonth()+1, //month "d+" : this.getDate(), //day "h+" : this.getHours(), //hour "m+" : this.getMinutes(), //minute "s+" : this.getSeconds(), //second "q+" : Math.floor((this.getMonth()+3)/3), //quarter "S" : this.getMilliseconds() //millisecond } if(/(y+)/.test(format)) format=format.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length)); for(var k in o)if(new RegExp("("+ k +")").test(format)) format = format.replace(RegExp.$1, RegExp.$1.length==1 ? o[k] : ("00"+ o[k]).substr((""+ o[k]).length)); return format; } Date.prototype.format = function(format) //author: meizz { var o = { "M+" : this.getMonth()+1, //month "d+" : this.getDate(), //day "h+" : this.getHours(), //hour "m+" : this.getMinutes(), //minute "s+" : this.getSeconds(), //second "q+" : Math.floor((this.getMonth()+3)/3), //quarter "S" : this.getMilliseconds() //millisecond } if(/(y+)/.test(format)) { format=format.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length)); } for(var k in o) { if(new RegExp("("+ k +")").test(format)) { format = format.replace(RegExp.$1, RegExp.$1.length==1 ? o[k] : ("00"+ o[k]).substr((""+ o[k]).length)); } } return format; } Date.parseDate = function(str, format) //author: meizz { var date = new Date(); var o = { "d+" : date.setDate, //day "y+" : date.setYear, //year "M+" : date.setMonth, //month "h+" : date.setHours, //hour "m+" : date.setMinutes, //minute "s+" : date.setSeconds, //second "S" : date.setMilliseconds //millisecond } var offsetArray = []; var offsetPattern = {}; var cloneFormat = new String(format); for(var k in o) { var offset = cloneFormat.search(new RegExp("("+ k +")")); if (offset >= 0) { offset = ("0000" + offset); offset = offset.substring(offset.length-4, offset.length); offsetArray[offsetArray.length] = offset; offsetPattern["p_" + offset] = k; var num = RegExp.$1.length; if (RegExp.$1 == "S") { num = "1,3"; } format = format.replace(RegExp.$1, "(//d{" + num + "})"); } } offsetArray = offsetArray.sort(); var m = str.match(new RegExp(format)); date.setDate(1); for (var i=0; i<offsetArray.length; i++) { var p = offsetPattern["p_" + offsetArray[i]]; var value = parseInt(m[i+1], 10); if (p == "M+") { value--; } o[p].call(date, value); } return date; } Number.prototype.format = function(format) { var retBuffer = []; if (!/^([^#^0^/.]*)([#,]*)([0,]*)(/.([0]*)([#^/.]*)([^#^0^/.]*)|([^#^0^/.]*))$/.test(format)) { throw new Error("无效格式定义[" + format + "]!"); } var prefix = RegExp.$1; var minDigitAfterDot = RegExp.$5.length; var maxDigitAfterDot = minDigitAfterDot + RegExp.$6.length; var subfix = RegExp.$7 || RegExp.$8; var minDigitBeforeDot = new String(RegExp.$3).replace(//,/g, "").length; var comInterval = 0; var fmtPart = format.split(","); var dotPart = fmtPart[fmtPart.length-1].split("."); if (fmtPart.length > 1) { comInterval = dotPart[0].length; } if (maxDigitAfterDot == 0) { comInterval -= subfix.length; } var value = "" + Math.round(this * Math.pow(10, maxDigitAfterDot)) * 1.0 / Math.pow(10, maxDigitAfterDot); var valuePart = value.split("."); var len = minDigitBeforeDot-valuePart[0].length; for (var i=0; i<len; i++) { valuePart[0] = "0" + valuePart[0]; } retBuffer.push(prefix); var flag = false; if (comInterval > 0) { var v = valuePart[0].length % comInterval; if (v>0) { retBuffer.push(valuePart[0].substr(0, v)); flag = true; } for (var i=v; i<valuePart[0].length; i+= comInterval) { if (flag) { retBuffer.push(","); } retBuffer.push(valuePart[0].substr(i, comInterval)); flag = true; } } else { retBuffer.push(valuePart[0]); } if (valuePart.length == 1) { valuePart[1] = ""; } if (minDigitAfterDot > 0) { retBuffer.push("."); } retBuffer.push(valuePart[1]); for (var i=valuePart[1].length; i<minDigitAfterDot; i++) { retBuffer.push("0"); } retBuffer.push(subfix); return retBuffer.join(""); } Number.parse = function (str, format) { if (!/^([^#^0^/.]*)([#,]*)([0,]*)(/.([0]*)([#^/.]*)([^#^0^/.]*)|([^#^0^/.]*))$/.test(format)) { throw new Error("无效格式定义[" + format + "]!"); } var prefix = RegExp.$1; var subfix = RegExp.$7 || RegExp.$8; var ret = str.substring(prefix.length, str.length-subfix.length); ret = ret.replace(//,/g, ""); return new Number(parseFloat(ret)); } String.prototype.trim = function() { // 用正则表达式将前后空格 // 用空字符串替代。 return this.replace(/(^/s*)|(/s*$)/g, ""); } function toObject(rows, map) { var retRows = []; for (var i=0; i<rows.length; i++) { var cols = rows[i]; retRows[i] = new Array(); for (var k=0; k<map.length; k++) { retRows[i][map[k]] = cols[k]; } } return retRows; } /* add by zhb for subaccount type*/ //99全部 10活期 13定期 var SUB_ACCOUNT_TYPE_ALL = "99"; var SUB_ACCOUNT_TYPE_LONG = "13"; var SUB_ACCOUNT_TYPE_SHORT = "10"; /* add by zhb end*/ //********************************** // added by lizhijian (start) // 06-08-02 // 交易界面功能完善:金额大小写自动转换 //********************************** function ChangeToBig(value){ if (value == null) { return "错误金额"; } value = "" + value; var intFen,i; var strArr,strCheck,nstrCheck,strFen,strDW,strNum,strBig,strNow; var v = -1; try { v = parseFloat(value); } catch (ex) { } if (isNaN(v) || v <= 0 || v > 999999999999.99) { return "错误金额"; } else if (v >= 1 && value.charAt(0) == '0') { return "错误金额"; } else if (value.charAt(0) == '+') { return "错误金额"; } if (value.indexOf("e") >=0 || value.indexOf("E") >=0) { return "错误金额"; } var strArray = value.split("."); if (strArray[1] && strArray[1].length > 2) { //小数点后面超过两位提示 return "错误金额"; } try { i = 0; strBig = ""; intFen = parseInt(value*100+0.00099999999); //转换为以分为单位的数值 strFen = intFen.toString(); strArr = strFen.split("."); strFen = strArr[0]; intFen = strFen.length; //获取长度 strArr = strFen.split(""); //将各个数值分解到数组内 while(intFen!=0) //分解并转换 { i = i+1; switch(i) //选择单位 { case 1:strDW = "分";break; case 2:strDW = "角";break; case 3:strDW = "元";break; case 4:strDW = "拾";break; case 5:strDW = "佰";break; case 6:strDW = "仟";break; case 7:strDW = "万";break; case 8:strDW = "拾";break; case 9:strDW = "佰";break; case 10:strDW = "仟";break; case 11:strDW = "亿";break; case 12:strDW = "拾";break; case 13:strDW = "佰";break; case 14:strDW = "仟";break; } switch (strArr[intFen-1]) //选择数字 { case "1":strNum = "壹";break; case "2":strNum = "贰";break; case "3":strNum = "叁";break; case "4":strNum = "肆";break; case "5":strNum = "伍";break; case "6":strNum = "陆";break; case "7":strNum = "柒";break; case "8":strNum = "捌";break; case "9":strNum = "玖";break; case "0":strNum = "零";break; } //处理特殊情况 strNow = strBig.split(""); //分为零时的情况 if((i==1)&&(strArr[intFen-1]=="0")) { strBig = "整"; } //角为零时的情况 else if((i==2)&&(strArr[intFen-1]=="0")) { //角分同时为零时的情况 if(strBig!="整") strBig = "零"+strBig; } //元为零的情况 else if((i==3)&&(strArr[intFen-1]=="0")) { strBig = "元"+strBig; } //拾-仟中一位为零且其前一位(元以上)不为零的情况时补零 else if((i<7)&&(i>3)&&(strArr[intFen-1]=="0")&&(strNow[0]!="零")&&(strNow[0]!="元")) { strBig = "零"+strBig; } //拾-仟中一位为零且其前一位(元以上)也为零的情况时跨过 else if((i<7)&&(i>3)&&(strArr[intFen-1]=="0")&&(strNow[0]=="零")){} //拾-仟中一位为零且其前一位是元且为零的情况时跨过 else if((i<7)&&(i>3)&&(strArr[intFen-1]=="0")&&(strNow[0]=="元")){} //当万为零时必须补上万字 else if((i==7)&&(strArr[intFen-1]=="0")) { strBig ="万"+strBig; } //拾万-仟万中一位为零且其前一位(万以上)不为零的情况时补零 else if((i<11)&&(i>7)&&(strArr[intFen-1]=="0")&&(strNow[0]!="零")&&(strNow[0]!="万")) { strBig = "零"+strBig; } //拾万-仟万中一位为零且其前一位(万以上)也为零的情况时跨过 else if((i<11)&&(i>7)&&(strArr[intFen-1]=="0")&&(strNow[0]=="万")){} //拾万-仟万中一位为零且其前一位为万位且为零的情况时跨过 else if((i<11)&&(i>7)&&(strArr[intFen-1]=="0")&&(strNow[0]=="零")){} //万位为零且存在仟位和十万以上时,在万仟间补零 else if((i<11)&&(i>8)&&(strArr[intFen-1]!="0")&&(strNow[0]=="万")&&(strNow[2]=="仟")) { strBig = strNum+strDW+"万零"+strBig.substring(1,strBig.length); } //单独处理亿位 else if(i==11) { //亿位为零且万全为零存在仟位时,去掉万补为零 if((strArr[intFen-1]=="0")&&(strNow[0]=="万")&&(strNow[2]=="仟")) { strBig ="亿"+"零"+strBig.substring(1,strBig.length); } //亿位为零且万全为零不存在仟位时,去掉万 else if((strArr[intFen-1]=="0")&&(strNow[0]=="万")&&(strNow[2]!="仟")) { strBig ="亿"+strBig.substring(1,strBig.length); } //亿位不为零且万全为零存在仟位时,去掉万补为零 else if((strNow[0]=="万")&&(strNow[2]=="仟")) { strBig = strNum+strDW+"零"+strBig.substring(1,strBig.length); } //亿位不为零且万全为零不存在仟位时,去掉万 else if((strNow[0]=="万")&&(strNow[2]!="仟")) { strBig = strNum+strDW+strBig.substring(1,strBig.length); } //其他正常情况 else { strBig = strNum+strDW+strBig; } } //拾亿-仟亿中一位为零且其前一位(亿以上)不为零的情况时补零 else if((i<15)&&(i>11)&&(strArr[intFen-1]=="0")&&(strNow[0]!="零")&&(strNow[0]!="亿")) { strBig = "零"+strBig; } //拾亿-仟亿中一位为零且其前一位(亿以上)也为零的情况时跨过 else if((i<15)&&(i>11)&&(strArr[intFen-1]=="0")&&(strNow[0]=="亿")){} //拾亿-仟亿中一位为零且其前一位为亿位且为零的情况时跨过 else if((i<15)&&(i>11)&&(strArr[intFen-1]=="0")&&(strNow[0]=="零")){} //亿位为零且不存在仟万位和十亿以上时去掉上次写入的零 else if((i<15)&&(i>11)&&(strArr[intFen-1]!="0")&&(strNow[0]=="零")&&(strNow[1]=="亿")&&(strNow[3]!="仟")) { strBig = strNum+strDW+strBig.substring(1,strBig.length); } //亿位为零且存在仟万位和十亿以上时,在亿仟万间补零 else if((i<15)&&(i>11)&&(strArr[intFen-1]!="0")&&(strNow[0]=="零")&&(strNow[1]=="亿")&&(strNow[3]=="仟")) { strBig = strNum+strDW+"亿零"+strBig.substring(2,strBig.length); } else { strBig = strNum+strDW+strBig; } strFen = strFen.substring(0,intFen-1); intFen = strFen.length; strArr = strFen.split(""); } return strBig; } catch(err) { return ""; //若失败则返回原值 } } //对大小写金额转换中的数据去掉逗号 function replaceComma(str){ str = str.replace(//,/g,""); return str; } function splitComma(str){ var strArray = str.split(','); var temp = ""; for(var i = 0;i < strArray.length; i++){ temp += strArray[i]; } return temp; } //**********added by lizhijian 06-08-02 (end)********** /*add by fanglifeng 07-02-12 cal submit time start*/ function getNowTimeString(inputString){ var newtimeString=""; try{ var long_beginDate=Date.parse(new Date()); var intervalTime=0; intervalTime=Date.parse(new Date())-Date.parse(beginDate); if(intervalTime<0){ intervalTime=0; } var newtimeString=Date.parse(Date.parseDate(inputString,"yyyy-MM-dd hh:mm:ss"))+intervalTime; newtimeString=new Date(newtimeString).format("yyyy-MM-dd hh:mm:ss"); } catch(e){ newtimeString=inputString; } return newtimeString; } /*add by fanglifeng 07-02-12 end*/