/*** 2010-7-13* 그는 Chen* Love* JS 다양한 양식 데이터 확인*//******************************************************************************************************************************************************************************* ********************************************************************************************************************************************************************************************** ********************************************************************************************************************************************************************************************** ********************************************************************************************************************************************************************************************** ********************************************************************************************************************************************************************************************** ********************************************************************************************************************************************************************************************** ********************************************************************************************************************************************************************************************** *********************************************************************************************************************************************************************************************** Verification of digital**********************************************************************************************************************************************************************************************************************//** * Check 입력 문자열이 모든 숫자인지* 입력 : str String* return : true 또는 flase; true는 숫자*/function checknum (str) {return str.match (// d/) == null;}/***로 표시됩니다. 입력 문자열이 소수점* 입력인지 확인하십시오 : str String* return : true 또는 flase; true는 10 진수*/함수 checkdecimal (str) {if (str.match (/^-?/d+(/./ d+)? $/g) == null) {return false; } else {return true; }}/*** 입력 문자열이 정수 데이터인지 확인* 입력 : str 문자열* return : true 또는 flase; true는 10 진수 */함수 checkinteger (str) {if (str.match (/^[-+]?/d *$/) == null로 표현됩니다. {return false; } else {return true; }}/*********************************************************************************//****************************************************************************************************************** *************************************************************************************************************************************************************************************************************************** * Check whether the input string is 문자* 입력 : str string* return : true 또는 flase; True는 모든 문자가 한자를 포함하지 않음을 의미합니다.*/function checkstr (str) {if (/;^/x00-/xff ]/g.test(str)) {return false; } else {return true; }}/*** 입력 문자열에 한자가 포함되어 있는지 확인하십시오* 입력 : str 문자열* 반환 : true 또는 flase; 참나 문자*/function checkinese (str) {if (Escape (str) .indexof ( "%u")! = -1) {return true; } else {return false; }}/*** 입력 된 사서함 형식이 올바른지 확인* 입력 : str string* return : true 또는 flase; true 형식이 올바른 의미*/function Checkemail (str) {if (str.match (/[a-za-z0-9 _-]+[@] (/s*) (net | com | cn | org | cc | tv | [0-9] {1,3}) (/s*)/g) == null) } else {return true; }}/*** 입력 된 휴대폰 번호가 올바른지 확인* 입력 : str string* return : true 또는 flase; True 형식이 정확하다는 의미*/함수 Checkmobilephone (str) {if (str.match (/^(? : 13/d | 15 [89])-?/d {5} (/d {3} |/*{3}) $/) == null) {return false; } else {return true; }}/*** 입력 된 유선 전화 번호가 올바른지 확인* : str string* return : true 또는 flase; true 형식이 올바른 의미*/function checktelephone (str) {if (str.match (/^([0/+]/d {2,3}-)? (0/d {2,3})-) (/d {7,8}) (-(/d {3,}))) == null) {반품; } else {return true; }}/*** QQ 형식이 올바른지 확인* : str string* return : true 또는 flase; true 형식이 올바른 의미*/function checkqq (str) {if (str.match (/^/d {5,10} $/) == null) {return false; } else {return true; }}/*** 입력 된 ID 번호가 올바른지 확인* 입력 : str string* return : true 또는 flase; True 형식이 올바른 의미*/function checkard (str) {// 15 자리 ID 카드 정규 표현식 var arg1 =/^[1-9]/d {7} (0/d) | (1 [0-2])) ([[0 | 1 | 2]/d) | 3 [0-1])/d {3} $/; // 18 자리 ID 카드 정규 표현식 var arg2 =/^[1-9]/d {5} [1-9]/d {3} (0/d) | (1 [0-2])) ([[0 | 1 | 2]/d) | 3 [0-1]) ((/d {4}) |/d {3} [az]) $/; if (str.match (arg1) == null && str.match (arg2) == null) {return false; } else {return true; }}/*** 입력 된 IP 주소가 올바른지 확인* 입력 : str string* return : true 또는 flase; True는 올바른 형식*/함수 checkip (str) {var arg =를 의미합니다 /^(/d {1,2 }|1/d/dowan2====-4 ]/dod|25, 5 ])/. . (/d {1,2} | 1/d/d | 2 [0-4]/d | 25 [0-5])/. (/d {1,2} | 1/d/d | 2 [0-4]/d | 25 [0-5]) $/; if (str.match (arg) == null) {return false; } else {return true; }}/*** 입력 URL 주소가 올바른지 확인* 입력 : str string* return : true 또는 flase; true 형식이 올바른 의미*/function checkurl (str) {if (str.match (/(http [s]? | ftp) :://////// [^///.]+? /..+/ w $/i) == null) {return false} else {return true; }}/*** 입력 문자에 특수 문자가 있는지 확인하십시오* 입력 : str string* return : true 또는 flase; 실제 문자*는 정보*/function checkquote (str) {var items = new Array ( "~", "`", "!", "@", "#", "$", "%", "^", ","*","{ ","} ","[ "", "(", ""); items.push ( ":", ";", "," ","| ","// ","< ","> ","? ","? ","<< ",">> ","|| ","// "); items.push ( "admin", "관리자", "관리자", "관리자", "관리자", "시스템 관리자"); items.push ( "select", "delete", "update", "insert", "create", "drop", "alter", "trancate"); str = str.tolowercase (); for (var i = 0; i <initem.length; i ++) {if (str.indexof (items [i])> = 0) {return true; } } return false;}/************************************************************************//************************************************Time Verification of ********************************************************************************************************************************************************************************************************************** * Check whether the date format is correct* 입력 : str string* return : true 또는 flase; True는 형식이 정확하다는 것을 의미합니다* 참고 : 중국 날짜 형식은 여기에서 확인할 수 없습니다* 짧은 날짜 (2007-06-05)*/function checkdate (str) {// var value = str.match (/(^((1 [8-9]/d {2}) | ([2-9]/d {3})) (-) (10 | 12 | 0? [13578]) ( -) (3 [01] | [12] [0-9] | 0? [469] (-) (30 | [12] [0-9] | 0? [2468] [048] 00) (-) (0? 2) (-) (29) $) | (^([2468] [048] 00) (-) (0? 2) (-) (29) $) | ([2468] [048] 00) (-) (0? 2) (-) (29) $) | (^ ([3579] [26] 00) (-) (0? 2) (-) (29) $) | (^([1] [89] [0] [48]) (-) (0? 2) (-) (29) $) | ^([2-9] [0-9] [0] [48]) (-) (0? 2) (-) (29) $) | (^([1] [89] [2468] [048]) (-) (0? 2) -) (29) $) | (^([2-9] [0-9] [2468] [048]) (-) (0? 2) (-) (29) $) | (^([1] [89] [13579] [26] (-) (0? 2) (-) (29) $) | (^([2-9] [0-9] [13579] [26]) (-) (0? 2) (-) (29) $)/); var value = str.match (/^(/d {1,4}) (-| //) (/d {1,2})/2 (/d {1,2}) $/); if (value == null) {return false; } else {var date = 새 날짜 (값 [1], 값 [3] -1, value [4]); return (date.getlyear () == value [1] && (date.getMonth () + 1) == value [3] && date.getDate () == value [4]); }}/*** 시간 형식이 올바른지 확인* 입력 : str string* return : true 또는 flase; true 형식이 올바른 의미 * 확인 시간 (10:57:10) */함수 checktime (str) {var value = str.match (/^(/d {1,2}) (:)? (/d {1,2})/2 (/d {1,2}) $/) if (value == null) {return false; } else {if (value [1]> 24 || value [3]> 60 || value [4]> 60) {return false} else {return true; }}}/*** 전체 날짜 시간 형식이 올바른지 확인* 입력 : str string* return : true 또는 flase; True 형식이 정확하다는 것을 의미합니다 * (2007-06-05 10:57:10) */function checkfulltime (str) {// var value = str.match (/^(/d {1,4}) (-| //) (/d {1,2})/2 (/d {1,2}) (/d {1,2}) : (/d {1,2}) : (/d {1,2}) $/); var value = str.match (/^(? : 19 | 20) [0-9] [0-9]-(? :(? : 0 [1-9]) | (? : 1 [0-2] [1-9]) | (? : [1-3] [0-1]))). (? : (? : [0-2] [0-3]) | (? : [0-1] [0-9])) : [0-5] [0-9] : [0-5] [0-9] $/); if (value == null) {return false; } else {// var date = new 날짜 (CheckfullTime [1], CheckfullTime [3] -1, CheckfullTime [4], CheckfullTime [5], CheckfullTime [6], CheckfullTime [7]); // return (date.getFelyEar () == value [1] && (date.getMonth () + 1) == value [3] && date.getDate () == value [4] && date.gethours () == value [5] && date.getMinutes () == value [6] && date [7]); 진실을 반환하십시오. } }/*********************************************************************************//****************************************************************** ID number Verification of ********************************************************************************************************************************************************************************************************** * 15-digit encoding rules for ID card: ddddddd yymmdd xx p* dddddd : 지역 코드 코드* yymmdd : 생년월일* xx : 순차적 클래스 인코딩, 결정할 수 없습니다* p : 성별, 홀수 번호는 남성입니다. yyyymmdd : 생년월일* xxx : 순차적 클래스 인코딩, 결정할 수없고, 홀수는 수컷이고, 숫자 숫자도 여성입니다* y : 검증 코드,이 숫자 값은 처음 17 자리* <p />*를 통해 얻을 수 있습니다. 2,1] * 검증 비트 y = [1, 0, 10, 9, 8, 7, 6, 5, 4, 3, 2] * 검증 비트 계산 공식 : y_p = mod (∑ (ai × wi), 11) * i는 오른쪽에서 왼쪽에서 왼쪽으로 ID 번호의 2 ... 18 자리입니다. y_p는 발 확인 코드가 위치한 검증 코드 배열 위치입니다 */var wi = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2, 1]; // 가중치 팩터 val validecode = [1, 0, 10, 9, 8, 7, 5, 4, 3, 2]; idcardValidate (idcard) {idcard = trim (idcard.replace ( / / g, ""); if (idcard.length == 15) {return isvaliditybrithby15idcard (idcard); } else if (idcard.length == 18) {var a_idcard = idcard.split ( ""); // ID 카드 배열을 가져옵니다. (isValidityBrithBy18idcard (idcard) && istruevalidatecodeby18idcard (a_idcard)) {reture true; } else {return false; }} else {return false; }}/*** ID 번호가 18 자리 일 때 마지막 확인 비트가 올바른지 여부를 결정하십시오* @param a_idcard ID 번호 배열* @return*/function istruevalidatecodeby18idcard (a_idcard) {var sum = 0; // 가중 합계 변수를 선언합니다. Sum % 11; // (a_idcard [17] == validecode [valcodeposition]) {return true; } else {return false; }}/*** ID 카드로 남자 또는 여자인지 결정* @param idcard 15/18 자리 ID 카드 번호* @return 'female'-female,'male'-male*/function maleorfemalbyidcard (idcard) {idcard = trim (idcard.replace (//g, ")); 캐릭터 사이의 공간을 포함합니다. if (idcard.length == 15) {if (idcard.substring (14, 15) % 2 == 0) {return 'female'; } else {return 'male'; }} else if (idcard.length == 18) {if (idcard.substring (14, 17) % 2 == 0) {return 'female'; } else {return 'male'; }} else {return null; }}/*** 18 자리 ID 번호의 생일이 유효한 생일인지 확인하십시오* @param idcard 18 자리 책 ID String* @return*/function isvaliditybrithby18idcard (idcard18) {var year = idcard18.substring (6, 10); var month = idcard18.substring (10, 12); var day = idcard18. 서브 스트링 (12, 14); var temp_date = 새 날짜 (연도, parsefloat (월) -1, parsefloat (day)); // (temp_date.getfillyear ()! = parsefloat () || temp_date.getmonth () = parsefloat (Month) -1 || temp_date.getDate.getDate.getDate.getDate.getDate.getDate.getDate.getDate.getDate.getDate.getDate.getDate.getDate.getDate.getDate.getDate.getDate.getDate (Return false; } else {return true; }}/*** 15 자리 ID 카드 번호의 생일이 유효한 생일인지 확인* @param idcard15 15 자리 책 ID 카드 문자열* @return*/function isvaliditybrithby15idcard (idcard15) {var year = idcard15.substring (6, 8); var month = idcard15.substring (8, 10); var day = idcard15.substring (10, 12); var temp_date = 새 날짜 (연도, parsefloat (월) -1, parsefloat (day)); // 이전 ID 카드에서 나이에 대해 밀레니엄 버그 문제를 고려하고 getyear () 메소드를 사용할 필요가 없습니다. if (temp_date.getyear ()! = parsefloat (he 년) || temp_date.getmonth ()! = parsefloat (month) -1 || temp_date.getdate () {parsefloat () {retury retury; } else {return true; }} // 스트링 헤드와 테일 스페이스 기능 트림 (str) {return str.replace (/(^/s*) | (/s*$)/g, "");}위는이 기사의 전체 내용입니다. JavaScript에 대한 자세한 내용은 "JavaScript 참조 자습서"및 "JavaScript Code Style Guide"를 확인하십시오. 또한 모두가 wulin.com을 더 지원하기를 바랍니다.