<div class="codetitle"> <span><a style="CURSOR: pointer" data="81995" class="copybut" id="copybut81995" onclick="doCopy('code81995')"><u>复代码</u></a></span> 代码如下:</div> <div class="codebody" id="code81995"> <br><script 언어="javascript" type="text/javascript" > <br>function CheckIdCardField(v_card) { <br>var reg = /^d{15}(d{2}[0-9X])?$/i; <br>if (!reg.test(v_card)) { <br>false를 반환합니다. <br>} <br>if (v_card.length == 15) { <br>var n = new Date(); <br>var y = n.getFullYear(); <br>if (parseInt("19" v_card.substr(6, 2)) < 1900 ||parseInt("19" v_card.substr(6, 2)) > y) { <br>return false; <br>} <br>varbirth = "19" v_card.substr(6, 2) "-" v_card.substr(8, 2) "-" v_card.substr(10, 2); <br>if (!isDate(birth)) { <br>false를 반환합니다. <br>} <br>} <br>if (v_card.length == 18) { <br>var n = new Date(); <br>var y = n.getFullYear(); <br>if (parseInt(v_card.substr(6, 4)) < 1900 || parseInt(v_card.substr(6, 4)) > y) { <br> false를 반환합니다. <br>} <br>varbirth = v_card.substr(6, 4) "-" v_card.substr(10, 2) "-" v_card.substr(12, 2); <br>if (!isDate(birth)) { <br>false를 반환합니다. <br>} <br>iW = 새 배열(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2, 1); <br>iSum = 0; <br>for (i = 0; i iC = v_card.charAt(i); <br>iVal = parsInt(iC); <br>iSum = iVal * iW[i]; <br>} <br>iJYM = iSum % 11; <br>if (iJYM == 0) sJYM = "1"; <br>else if (iJYM == 1) sJYM = "0"; <br>else if (iJYM == 2) sJYM = "x"; <br>else if (iJYM == 3) sJYM = "9"; <br>else if (iJYM == 4) sJYM = "8"; <br>else if (iJYM == 5) sJYM = "7"; <br>else if (iJYM == 6) sJYM = "6"; <br>else if (iJYM == 7) sJYM = "5"; <br>else if (iJYM == 8) sJYM = "4"; <br>else if (iJYM == 9) sJYM = "3"; <br>else if (iJYM == 10) sJYM = "2"; <br>var cCheck = v_card.charAt(17).toLowerCase(); <br>if (cCheck != sJYM) { <br>false를 반환; <br>} <br>} <br>true를 반환합니다. <br>} <br></script> <br> </div>