ฟังก์ชั่นรหัสการตรวจสอบบัตรประจำตัวประชาชน
FunctionCheckCardid (E)
arrverifyCode = split ("1,0, x, 9,8,7,6,5,4,3,2", ",")
WI = Split ("7,9,10,5,8,4,2,1,1,6,3,7,9,10,5,8,4,2,2", ",")
Checker = Split ("1,9,8,7,6,5,4,3,2,1,1,1", ","), ")
iflen (e) <15orlen (e) = 16orlen (e) = 17orlen (e)> 18 จากนั้น
checkcardid = "หมายเลข id มี 15 รหัสหรือทั้งหมด 18 หลัก"
checkcardid = false
exitfunction
endif
ดิมิ
iflen (e) = 18 จากนั้น
ai = mid (e, 1,17)
elseiflen (e) = 15 จากนั้น
ai = e
AI = ซ้าย (AI, 6) & "19" & Mid (AI, 7,9)
endif
ifnotisnumeric (ai) แล้ว
checkcardid = "ยกเว้นตัวเลขสุดท้ายบัตรประจำตัวประชาชนจะต้องเป็นตัวเลข!"
exitfunction
endif
Dimstryear, strmonth, strday
Stryear = Cint (Mid (AI, 7,4))
strmonth = cint (mid (ai, 11,2))
stray = cint (กลาง (AI, 13,2))
วันเกิด = trim (Stryear)+"-"+trim (strmonth)+"-"+trim (strday)
ifisdate (วันเกิด) จากนั้น
ifdatediff ("yyyy" ตอนนี้วันเกิด) <-140orcdate (วันเกิด)> วันที่ () แล้ว
checkcardid = "บัตรประจำตัวเข้าไม่ถูกต้อง!"
exitfunction
endif
ifstrmonth> 12orstday> 31 จากนั้น
checkcardid = "บัตรประจำตัวเข้าไม่ถูกต้อง!"
exitfunction
endif
อื่น
checkcardid = "บัตรประจำตัวเข้าไม่ถูกต้อง!"
exitfunction
endif
Dimi, TotalMulaiwi
fori = 0to16
TotalMulaiwi = TotalMulaiwi+Cint (Mid (AI, I+1,1))*WI (i)
ต่อไป
dimmodvalue
modValue = TotalMulaiwimod11
dimstrverifyCode
strverifyCode = arrverifyCode (modValue)
ai = ai & strverifyCode
checkcardid = ai
iflen (e) = 18ande <> aithen
checkcardid = "หมายเลขบัตรประจำตัวเข้าไม่ถูกต้อง!"
exitfunction
endif
endfunction
Response.writeCheckCardid ("528337194801020025") '' '' '' '' '' '' 'ฉันไม่รู้ว่ามันคือบัตรประจำตัวของใคร
'' '' 'สิ่งนี้หากป้อนบัตรประจำตัวที่ส่งคืนหมายความว่ามันถูกต้องมิฉะนั้นจะมีข้อผิดพลาดเกิดขึ้น ...