String.prototype.trim = function() { return this.replace(/(^\s*)|(\s*$)/g, ""); } function chkFrmSubmit(frm){ for(var i=0;i10) { goodDate=false; } if (thenum1<1 || thenum1>12) { goodDate=false; } if (thenum2<1 || thenum2>31) { goodDate=false; } if (theChar1<"0" || theChar1>"9" ) { goodDate=false; } if (theChar2<"0" || theChar2>"9" ) { goodDate=false; } if (theChar3<"0" || theChar3>"9" ) { goodDate=false; } if (theChar4<"0" || theChar4>"9" ) { goodDate=false; } if (theChar6<"0" || theChar6>"9" ) { goodDate=false; } if (theChar7<"0" || theChar7>"9" ) { goodDate=false; } if (theChar9<"0" || theChar9>"9" ) { goodDate=false; } if (theChar10<"0" || theChar10>"9" ) { goodDate=false; } if (theChar5=="-" && theChar8=="-") { sepChar=true; } if (goodDate==false || sepChar==false) {alert ("鏃ユ湡涓嶈兘涓虹┖鎴栨牸寮忛敊璇細姝g‘涓�(YYYY-MM-DD)") return false;} return true; } function chkFloat(frmField){ var num=parseFloat(frmField.value).toString(); if (num.length!=frmField.value.length||num=='NaN'){ alert("鍏夋爣鎵�鍦ㄥ瓧娈电殑杈撳叆蹇呴』鏄纭殑鏁板瓧!") frmField.select(); return false; }; num = parseFloat(frmField.value) if(numfrmField.gmpa_maxlength){ alert("鍏夋爣鎵�鍦ㄥ瓧娈电殑杈撳叆涓嶈兘瓒呭嚭鑼冨洿!") frmField.select(); return false; } // return true; } function chkDateEmpty(frmField){ var theInput=frmField.value; if (theInput != ""){ var theLength=theInput.length; var goodDate=true; var sepChar=false; var theChar1=theInput.substring(0,1); var theChar2=theInput.substring(1,2); var theChar3=theInput.substring(2,3); var theChar4=theInput.substring(3,4); var theChar5=theInput.substring(4,5);//5 var theChar6=theInput.substring(5,6); var theChar7=theInput.substring(6,7); var theChar8=theInput.substring(7,8);//8 var theChar9=theInput.substring(8,9); var theChar10=theInput.substring(9,10); var thenum1=theInput.substring(5,7); var thenum2=theInput.substring(8,10); if (theLength<10 || theLength>10) { goodDate=false; } if (thenum1<1 || thenum1>12) { goodDate=false; } if (thenum2<1 || thenum2>31) { goodDate=false; } if (theChar1<"0" || theChar1>"9" ) { goodDate=false; } if (theChar2<"0" || theChar2>"9" ) { goodDate=false; } if (theChar3<"0" || theChar3>"9" ) { goodDate=false; } if (theChar4<"0" || theChar4>"9" ) { goodDate=false; } if (theChar6<"0" || theChar6>"9" ) { goodDate=false; } if (theChar7<"0" || theChar7>"9" ) { goodDate=false; } if (theChar9<"0" || theChar9>"9" ) { goodDate=false; } if (theChar10<"0" || theChar10>"9" ) { goodDate=false; } if (theChar5=="-" && theChar8=="-") { sepChar=true; } if (goodDate==false || sepChar==false) {alert ("鏃ユ湡鏍煎紡閿欒锛氭纭负(YYYY-MM-DD)") return false;} } return true; } function chkEMail(frmField) { var format=/^[_A-Za-z0-9.-]+@([_A-Za-z0-9-]+\.)+[A-Za-z0-9]{2,3}$/; if (frmField.value !="" && !format.test(frmField.value)){ var msg = frmField.getAttribute("msg") != null ? frmField.getAttribute("msg") : "鐢靛瓙閭鏍煎紡涓嶆纭�<濡傦細yourname@company.com>."; alertMsg(msg, frmField); return false; } return true ; } function chkMobile(frmField){ var regu =/^[1][358]{1}[0-9]{9}$/; var re = new RegExp(regu); if (frmField.value !="" && !re.test(frmField.value)) { var msg = frmField.getAttribute("msg") != null ? frmField.getAttribute("msg") : "鎵嬫満鍙风爜鏍煎紡涓嶆纭�!"; alertMsg(msg, frmField); return false; } return true ; } function chkPhone(frmField) { var phoneReg = /^(([0\+]\d{2,3}-)?(0\d{2,3})-)?(\d{7,8})(-(\d{3,}))?$/; if(frmField.value != '' && !phoneReg.test(frmField.value)){ var msg = frmField.getAttribute("msg") != null ? frmField.getAttribute("msg") : "鐢佃瘽鍙风爜鏍煎紡涓嶆纭�!"; alertMsg(msg, frmField); return false; } return true ; } var v_card_check_city = {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:"鍥藉" }; function chkCard(frmField) { var msg = frmField.getAttribute("msg") != null ? frmField.getAttribute("msg") : "韬唤璇佹牸寮忎笉姝g‘!"; if(frmField.value != ''){ var card = frmField.value; // 鏍¢獙闀垮害锛岀被鍨� if(isCardNo(card) === false) { alertMsg(msg, frmField); return false; } // 妫�鏌ョ渷浠� if(checkProvince(card) === false) { alertMsg(msg, frmField); return false; } // 鏍¢獙鐢熸棩 if(checkBirthday(card) === false) { alertMsg(msg, frmField); return false; } // 妫�楠屼綅鐨勬娴� if(checkParity(card) === false) { alertMsg(msg, frmField); return false; } } return true; } function alertMsg(msg, frmField){ alert(msg); frmField.focus(); frmField.select(); } // 妫�鏌ュ彿鐮佹槸鍚︾鍚堣鑼冿紝鍖呮嫭闀垮害锛岀被鍨� function isCardNo(card) { // 韬唤璇佸彿鐮佷负15浣嶆垨鑰�18浣嶏紝15浣嶆椂鍏ㄤ负鏁板瓧锛�18浣嶅墠17浣嶄负鏁板瓧锛屾渶鍚庝竴浣嶆槸鏍¢獙浣嶏紝鍙兘涓烘暟瀛楁垨瀛楃X var reg = /(^\d{15}$)|(^\d{17}(\d|X)$)/; if(reg.test(card) === false) { return false; } return true; } // 鍙栬韩浠借瘉鍓嶄袱浣�,鏍¢獙鐪佷唤 function checkProvince(card) { var province = card.substr(0,2); if(v_card_check_city[province] == undefined) { return false; } return true; } // 妫�鏌ョ敓鏃ユ槸鍚︽纭� function checkBirthday(card) { var len = card.length; // 韬唤璇�15浣嶆椂锛屾搴忎负鐪侊紙3浣嶏級甯傦紙3浣嶏級骞达紙2浣嶏級鏈堬紙2浣嶏級鏃ワ紙2浣嶏級鏍¢獙浣嶏紙3浣嶏級锛岀殕涓烘暟瀛� if(len == '15') { var re_fifteen = /^(\d{6})(\d{2})(\d{2})(\d{2})(\d{3})$/; var arr_data = card.match(re_fifteen); var year = arr_data[2]; var month = arr_data[3]; var day = arr_data[4]; var birthday = new Date('19'+year+'/'+month+'/'+day); return verifyBirthday('19'+year,month,day,birthday); } // 韬唤璇�18浣嶆椂锛屾搴忎负鐪侊紙3浣嶏級甯傦紙3浣嶏級骞达紙4浣嶏級鏈堬紙2浣嶏級鏃ワ紙2浣嶏級鏍¢獙浣嶏紙4浣嶏級锛屾牎楠屼綅鏈熬鍙兘涓篨 if(len == '18') { var re_eighteen = /^(\d{6})(\d{4})(\d{2})(\d{2})(\d{3})([0-9]|X)$/; var arr_data = card.match(re_eighteen); var year = arr_data[2]; var month = arr_data[3]; var day = arr_data[4]; var birthday = new Date(year+'/'+month+'/'+day); return verifyBirthday(year,month,day,birthday); } return false; } // 鏍¢獙鏃ユ湡 function verifyBirthday(year,month,day,birthday) { var now = new Date(); var now_year = now.getFullYear(); // 骞存湀鏃ユ槸鍚﹀悎鐞� if(birthday.getFullYear() == year && (birthday.getMonth() + 1) == month && birthday.getDate() == day) { // 鍒ゆ柇骞翠唤鐨勮寖鍥达紙3宀佸埌100宀佷箣闂�) var time = now_year - year; if(time >= 3 && time <= 100) { return true; } return false; } return false; } // 鏍¢獙浣嶇殑妫�娴� function checkParity(card) { // 15浣嶈浆18浣� card = changeFivteenToEighteen(card); var len = card.length; if(len == '18') { var arrInt = new Array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2); var arrCh = new Array('1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'); var cardTemp = 0, i, valnum; for(i = 0; i < 17; i ++) { cardTemp += card.substr(i, 1) * arrInt[i]; } valnum = arrCh[cardTemp % 11]; if (valnum == card.substr(17, 1)) { return true; } return false; } return false; } // 15浣嶈浆18浣嶈韩浠借瘉鍙� function changeFivteenToEighteen(card) { if(card.length == '15') { var arrInt = new Array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2); var arrCh = new Array('1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'); var cardTemp = 0, i; card = card.substr(0, 6) + '19' + card.substr(6, card.length - 6); for(i = 0; i < 17; i ++) { cardTemp += card.substr(i, 1) * arrInt[i]; } card += arrCh[cardTemp % 11]; return card; } return card; } function fPopUpDlg(endtarget,ctl,WINname,WINwidth,WINheight){ showx = WINwidth + 200 ; // + deltaX; showy = WINheight ; // + deltaY; newWINwidth = WINwidth + 4 + 18; var features = 'dialogWidth:' + newWINwidth + 'px;' + 'dialogHeight:' + WINheight + 'px;' + 'dialogLeft:' + showx + 'px;' + 'dialogTop:' + showy + 'px;' + 'directories:no; localtion:no; menubar:no; status=no; toolbar=no;scrollbars:yes;Resizeable=no'; retval = window.showModalDialog(endtarget, WINname , features ); if( retval != null ){ ctl.value = retval; }else{ //alert("canceled"); } } function TransformCN(number) { number=new String(parseFloat(number).toFixed(2)); //鍒嗙鏁存暟涓庡皬鏁� var num; var dig; if(number.indexOf(".") == -1) { num = number; dig = ""; } else { num = number.substr(0,number.indexOf(".")); dig = number.substr( number.indexOf(".")+1, number.length); } //杞崲鏁存暟閮ㄥ垎 var i=1; var len = num.length; var dw2 = new Array("","涓�","浜�");//澶у崟浣� var dw1 = new Array("鎷�","浣�","鍗�");//灏忓崟浣� var dw = new Array("","澹�","璐�","鍙�","鑲�","浼�","闄�","鏌�","鎹�","鐜�");//鏁存暟閮ㄥ垎鐢� var dws = new Array("闆�","澹�","璐�","鍙�","鑲�","浼�","闄�","鏌�","鎹�","鐜�");//灏忔暟閮ㄥ垎鐢� var k1=0;//璁″皬鍗曚綅 var k2=0;//璁″ぇ鍗曚綅 var str=""; for(i=1;i<=len;i++) { var n = num.charAt(len-i); if(n=="0") { if(k1!=0) str = str.substr(1,str.length-1); if(str.substr(0,1)!="闆�" && str.substr(0,1)!="涓�" && str.substr(0,1)!="浜�") { str="闆�"+str; } } str = dw[Number(n)].concat(str);//鍔犳暟瀛� if(len-i-1>=0)//鍦ㄦ暟瀛楄寖鍥村唴 { if(k1!=3)//鍔犲皬鍗曚綅 { str = dw1[k1].concat(str); k1++; } else//涓嶅姞灏忓崟浣嶏紝鍔犲ぇ鍗曚綅 { k1=0; var temp = str.charAt(0); if(temp=="涓�" || temp=="浜�")//鑻ュぇ鍗曚綅鍓嶆病鏈夋暟瀛楀垯鑸嶅幓澶у崟浣� str = str.substr( 1, str.length-1); str = dw2[k2].concat(str); } } if(k1==3)//灏忓崟浣嶅埌鍗冨垯澶у崟浣嶈繘涓� { k2++; } } if(str.substr(str.length-1,str.length)=="闆�") { str=str.substr(0,str.length-1); } //杞崲灏忔暟閮ㄥ垎 var strdig=""; if(Number(dig)==0) { strdig="鏁�"; } else { for(i=0;i<2;i++) { var n = dig.charAt(i); if(i==0 && Number(n)==0) { strdig="闆�" } else { strdig += dws[Number(n)]+(i==0 ? "瑙�" : "鍒�");//鍔犳暟瀛� } } } str += "鍏�"+strdig; return str; }