//op鏄緭鍏ョ殑Int瀛楃涓� //杩斿洖鏄纭殑鏁村瀷鏁板瓧锛宯ull鏄敊璇殑 function ToInt(op) { var num, exp; exp = /^\s*[-\+]?\d+\s*$/; if (op.match(exp) == null){ return null; } else{ num = parseInt(op, 10); //window.alert(num); //window.alert(isNAN(num)); return (isNaN(num) ? null : num); } } //op鏄緭鍏ョ殑Float瀛楃涓� //杩斿洖鏄纭殑Float鏁板瓧锛宯ull鏄敊璇殑 function ToFloat(op) { var num, cleanInput, m, exp; exp = new RegExp("^\\s*([-\\+])?(\\d+)?(\\.(\\d+))?\\s*$"); m = op.match(exp); if (m == null) return null; cleanInput = m[1] + (m[2].length>0 ? m[2] : "0") + "." + m[4]; num = parseFloat(cleanInput); return (isNaN(num) ? null : num); } function isIDCode(op) { tmpDate = new Date(); year= tmpDate.getYear(); if(ToInt(op.substr(0,op.length-1))==null) { return false; } else { if(op.length!=15&&op.length!=18) { return false; } if(op.length==15&&(parseInt(op.substr(8,2),10)==0||parseInt(op.substr(8,2),10)>12||parseInt(op.substr(10,2),10)==0||parseInt(op.substr(10,2),10)>31)) { return false; } if(op.length==18&&(parseInt(op.substr(6,4),10)<(parseInt(year)-60)||parseInt(op.substr(6,4),10)>parseInt(year)||parseInt(op.substr(10,2),10)==0||parseInt(op.substr(10,2),10)>12||parseInt(op.substr(12,2),10)==0||parseInt(op.substr(12,2),10)>31)) { return false; } } return true; } function checkIdcard(idcard){ var Errors=new Array( "ok", "韬唤璇佸彿鐮佷綅鏁颁笉瀵�!", "韬唤璇佸彿鐮佸嚭鐢熸棩鏈熻秴鍑鸿寖鍥存垨鍚湁闈炴硶瀛楃!", "韬唤璇佸彿鐮佹牎楠岄敊璇�!", "韬唤璇佸湴鍖洪潪娉�!" ); 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(""); //韬唤鍙风爜浣嶆暟鍙婃牸寮忔楠� 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]; break; } 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]$/;//骞冲勾鍑虹敓鏃ユ湡鐨勫悎娉曟�ф鍒欒〃杈惧紡 } //2000骞翠互鍚庡嚭鐢熺殑鏍¢獙 if ( parseInt(idcard.substr(6,4)) % 4 == 0 || (parseInt(idcard.substr(6,4)) % 100 == 0 && parseInt(idcard.substr(6,4))%4 == 0 )){ ereg20=/^[1-9][0-9]{5}20[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 { ereg20=/^[1-9][0-9]{5}20[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)||ereg20.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].toUpperCase()) return Errors[0]; //妫�娴婭D鐨勬牎楠屼綅 else return Errors[3]; } else return Errors[2]; break; default: return Errors[1]; break; } //鍦板尯妫�楠� if(area[parseInt(idcard.substr(0,2))]==null) return Errors[4]; } /*function isIDCode(op,gender) { tmpDate = new Date(); year= tmpDate.getYear(); if(ToInt(op.substr(0,op.length-1))==null) { return false; } else { if(op.length!=15&&op.length!=18) { return false; } if(op.length==15&&(parseInt(op.substr(8,2),10)==0||parseInt(op.substr(8,2),10)>12||parseInt(op.substr(10,2),10)==0||parseInt(op.substr(10,2),10)>31)) { return false; } if(op.length==18&&(parseInt(op.substr(6,4),10)<(parseInt(year)-60)||parseInt(op.substr(6,4),10)>parseInt(year)||parseInt(op.substr(10,2),10)==0||parseInt(op.substr(10,2),10)>12||parseInt(op.substr(12,2),10)==0||parseInt(op.substr(12,2),10)>31)) { return false; } if(gender!="") { if(op.length==15&&parseInt(op)%2!=parseInt(gender)%2) { return false; } if(op.length==18&&parseInt(op.substr(16,1),10)%2!=parseInt(gender)%2) { return false; } } } return true; }*/ function isZip(op) { if(op!=null&&op.length!=6) { return false; } if(op!=null&&ToInt(op)==null) { return false; } return true; } //javascript:鍘诲墠鍚庣┖鏍肩殑鏂规硶 /*function trim(value){ 銆�銆� return value.replace(/(^\s+)|(\s+$)/g,""); }*/ /* ================================================================== LTrim(string) : Returns a copy of a string without leading spaces. ================================================================== */ function LTrim(str) /* PURPOSE: Remove leading blanks from our string. IN: str - the string we want to LTrim */ { var whitespace = new String(" \t\n\r"); var s = new String(str); if (whitespace.indexOf(s.charAt(0)) != -1) { // We have a string with leading blank(s)... var j=0, i = s.length; // Iterate from the far left of string until we // don't have any more whitespace... while (j < i && whitespace.indexOf(s.charAt(j)) != -1) j++; // Get the substring from the first non-whitespace // character to the end of the string... s = s.substring(j, i); } return s; } /* ================================================================== RTrim(string) : Returns a copy of a string without trailing spaces. ================================================================== */ function RTrim(str) /* PURPOSE: Remove trailing blanks from our string. IN: str - the string we want to RTrim */ { // We don't want to trip JUST spaces, but also tabs, // line feeds, etc. Add anything else you want to // "trim" here in Whitespace var whitespace = new String(" \t\n\r"); var s = new String(str); if (whitespace.indexOf(s.charAt(s.length-1)) != -1) { // We have a string with trailing blank(s)... var i = s.length - 1; // Get length of string // Iterate from the far right of string until we // don't have any more whitespace... while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1) i--; // Get the substring from the front of the string to // where the last non-whitespace character is... s = s.substring(0, i+1); } return s; } /* ============================================================= Trim(string) : Returns a copy of a string without leading or trailing spaces ============================================================= */ function trim(str) /* PURPOSE: Remove trailing and leading blanks from our string. IN: str - the string we want to Trim RETVAL: A Trimmed string! */ { return RTrim(LTrim(str)); } //op鏄緭鍏ョ殑Date瀛楃涓� //杩斿洖鏄纭殑Date锛宯ull鏄敊璇殑 function ToDate(op) { function GetFullYear(year) { return (year + parseInt(2000)) - ((year < 2029) ? 0 : 100); } var num, m, exp; var yearFirstExp = new RegExp("^\\s*(\\d{4})[\-](\\d{2})[\-](\\d{2})\\s*$"); m = op.match(yearFirstExp); var day, month, year; if (m != null) { day = m[3]; month = m[2]; year = m[1] } month -= 1; var date = new Date(year, month, day); return (typeof(date) == "object" && year == date.getFullYear() && month == date.getMonth() && day == date.getDate()) ? date.valueOf() : null; } //op鏄緭鍏ョ殑Date瀛楃涓� //dateorder鏄棩璧锋牸寮忥細1銆亂md; 2銆乵dy; //杩斿洖鏄纭殑Date锛宯ull鏄敊璇殑 /*function ToDate(op, dateorder) { function GetFullYear(year) { return (year + parseInt(2000)) - ((year < 2029) ? 0 : 100); } var num, m, exp; var yearFirstExp = new RegExp("^\\s*((\\d{4})|(\\d{2}))([-./])(\\d{1,2})\\4(\\d{1,2})\\s*$"); m = op.match(yearFirstExp); var day, month, year; if (m != null && (m[2].length == 4 || dateorder == "ymd")) { day = m[6]; month = m[5]; year = (m[2].length == 4) ? m[2] : GetFullYear(parseInt(m[3], 10)) } else { if (dateorder == "ymd"){ return null; } var yearLastExp = new RegExp("^\\s*(\\d{1,2})([-./])(\\d{1,2})\\2((\\d{4})|(\\d{2}))\\s*$"); m = op.match(yearLastExp); if (m == null) { return null; } if (dateorder == "mdy") { day = m[3]; month = m[1]; } else { day = m[1]; month = m[3]; } year = (m[5].length == 4) ? m[5] : GetFullYear(parseInt(m[6], 10)) } month -= 1; var date = new Date(year, month, day); return (typeof(date) == "object" && year == date.getFullYear() && month == date.getMonth() && day == date.getDate()) ? date.valueOf() : null; }*/ //guqing:2005-05-08 楠岃瘉Email鐨勬牸寮� function isEmail(strEmail) { reg=/^\w{3,}@\w+(\.\w+)+$/; if(!reg.test(strEmail)){ return false; }else{ return true; } /* if (strEmail.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1) return true; else return false;*/ } //guqing:2005-05-08 楠岃瘉鏂囨湰妗嗗彧鑳借緭鍏ユ暟瀛楋紙濡傛墜鏈簊jhm锛� function onlyNum() { if(!((event.keyCode>=48&&event.keyCode<=57)||(event.keyCode>=96&&event.keyCode<=105)||(event.keyCode==127)||(event.keyCode==8)||(event.keyCode==46)||(event.keyCode>=37&&event.keyCode<=40))) //鑰冭檻灏忛敭鐩樹笂鐨勬暟瀛楅敭 event.returnValue=false; }