ID card number verification function

xiaoxiao2021-03-06  49

Function checkidcard (SSTR, BYVAL DDATE, BYVAL NSEX)? CheckidCard = "false"? If isnull (sstr) or sstr = "" THEN EXIT FUNCTION? If not isdate (ddate) or ddate = "" "· EXIT FUNCTION? IF ISNUMERIC (NSEX) or nsex = "" THEN EXIT FUNCTION ?? Dim Ore, sdate ?? set ore ?? = new regexp? ore.IgnoreCase? = true? ore @ = cint (NSEX MOD 2 )? sdate? = year (ddate) & dblnum (Month)) & dblnum (DDATE)) ?? SELECT CASE LEN (SSTR) ?? Case 8 ??? if Datediff ("YYYY", DDATE, DATE ()) <19 exit function ??? ore.pattern? = "^ [/ D] {8} $" ??? if not ore.test (sstr) THEN EXIT FUNCTION ??? IF SSTR <> SDATE THEN EXIT FUNCTION ?? Case 15 ??? ore.pattern? = "^ [/ D] {15} $" ??? if not ore.test (sstr) THEN EXIT FUNCTION ??? IF MID (SSTR, 7, 6 <> Right (SDATE, 6) THEN EXIT FUNCTION ??? IF CINT (MID (SSTR, 14, 1)) MOD 2 <> NSEX THEN EXIT FUNCTION ?? Case 18 ??? Ore.pattern? = "^ ( ?: [/ d] {18} | [/ d] {17} x) $ "??? if not ore.test (sstr) THEN EXIT FUNCTION ??? IF MID (SSTR, 7, 8) <> SDATE THEN EXIT FUNCTION ??? IF CINT (MID (SSTR, 17, 1)) MOD 2 <> NSEX THEN EXIT FUN CTION ?????? DIM NN, AW, AC, NL ?????? nn = 0 ??? AW = array (7, 9, 10, 5, 8, 4, 2, 1, 6, 3 , 7, 9, 10, 5, 8, 4, 2) ??? AC = Array ("1", "0", "X", "9", "8", "7", "6", "5", "4", "3", "2") ?????? for nl = 1 to 17 ???? NN = NN CINT (MID (SSTR, NL, 1)) * AW NL - 1) ??? Next ?????? IF ucase (Right (SSTR, 1)) <> ac (nn mod 11) Then EXIT FUNIT FUNCTION? ELSE ??? EXIT FUNCTION? End Select ?? set Ore ?? = nothing ?? checkidcard = "true" end functionfunction dblnum (nnum)? DBLNUM =

NNum? if dblnum <10 Then dblnum = "0" & ​​dblnumend function

Function checkidcard (s, d, g) {if (! s) return false; d = new date (d); if (! D.gettime ()) Return False; Var T, R; T = "" D. GetFullyear () DBLNUM (D.GETMONTH () 1) DBLNUM ()); if (g == NULL || ISNAN (G)) Return False; g = parseint (g)% 2; switch (S.Length) {case 8: IF (new date ()> d.setFullyear (D.Getfullyear () 19)) RETURN FALSE; R = / ^ [/ d] {8} $ /; if (! r .test (s)) Return False; if (s! = t) Return False; Break; Case 15: r = / ^ [/ d] {15} $ /; if (! r.test (s)) Return False ; if (S.Substr (6, 6)! = T.Substr (2)) Return False; if (Parseint (S.Charat (14))% 2! = g) Return False; Break; Case 18: r = / ^ (?: [/ d] {18} | [/ d] {17} x) $ / i; if (! r.test (s)) Return False; if (S.Substr (6, 8)! = T) Return False; if (S.Charat (S.Charat (16))% 2! = g) Return False; var n = 0; Var W = New Array (7, 9, 10, 5, 8, 4, 2 , 1, 6, 3, 7, 9, 10, 5, 8, 4); // Weighted Factor Var C = New Array ("1", "0", "X", "9", "8 "" 7 "," 6 "," 5 "," 4 "," 3 "," 2 "); // check code for (var i = 0; i <17; i ) {n = parseint (S.Charat (i)) * w [i];} if (s .CHARAT (17) .touppercase ()! = c [n% 11]) Return false; break; default: return false;} Return true;} function dblnum (n) {RETURN PARSEINT (N) <10? "0" N: N;} // var sss = "422324860305482"; //Response.write(Checkidcard(sss, "03/05/1986", 0));

转载请注明原文地址:https://www.9cbs.com/read-116274.html

New Post(0)