<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 language="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>return 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>return 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>return false; <BR>} <BR>varbirth = v_card.substr(6, 4) "-" v_card.substr(10, 2) "-" v_card.substr(12, 2); <BR>if (!isDate(birth)) { <BR>return false; <BR>} <BR>iW = new Array(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 <17; i ) { <BR>iC = v_card.charAt(i); <BR>iVal = parseInt(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>return false; <BR>} <BR>} <BR>true を返します。 <BR>} <BR></script> <br> </div>