当前位置: 首页 > 图文教程 > 网络编程 > ASP > asp身份证验证代码函数

ASP
javascript css 三级目录(简单的)
asp下sql和access数据库随机取10条记录的代码newid()
新增加一个防垃圾评论的asp代码,鄙视垃圾
asp ADO GetString函数与用GetString来提高ASP的速度
windows2003下使用asp WScript.Shell的设置方法
asp UTF-8 乱码问题的解决方法小结
JavaScript面向对象的两种书写方法以及差别
响应对象 错误 ''ASP 0185 : 80020003'' 缺少默认属性
ASP生成伪参数程序设计技巧
asp中使用mysql数据库的注意实现
使用FSO修改文件夹的名称实现文件转移防盗链
asp下request.querystring("id")与request("id")区别
asp将全角的字符转变成半角字符,将半角转变成全角d的代码
asp创建表,复制表 字段类型附录
asp加密解密函数decrypt
asp获取当前网页地址的代码
asp下经常用到的代码
asp 的中文分词
修改正确的asp冒泡排序
rustysun同学ASP代码书写规范

ASP 中的 asp身份证验证代码函数


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-13   浏览: 32 ::
收藏到网摘: n/a

身份证验证代码函数
Function CheckCardId(e)
arrVerifyCode = Split("1,0,x,9,8,7,6,5,4,3,2", ",")
Wi = Split("7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2", ",")
Checker = Split("1,9,8,7,6,5,4,3,2,1,1", ",")
If Len(e) < 15 Or Len(e) = 16 Or Len(e) = 17 Or Len(e) > 18 Then
CheckCardId= "身份证号共有 15 码或18位"
CheckCardId = False
Exit Function
End If
Dim Ai
If Len(e) = 18 Then
Ai = Mid(e, 1, 17)
ElseIf Len(e) = 15 Then
Ai = e
Ai = Left(Ai, 6) & "19" & Mid(Ai, 7, 9)
End If
If Not IsNumeric(Ai) Then
CheckCardId= "身份证除最后一位外,必须为数字!"
Exit Function
End If
Dim strYear, strMonth, strDay
strYear = CInt(Mid(Ai, 7, 4))
strMonth = CInt(Mid(Ai, 11, 2))
strDay = CInt(Mid(Ai, 13, 2))
BirthDay = Trim(strYear) + "-" + Trim(strMonth) + "-" + Trim(strDay)
If IsDate(BirthDay) Then
If DateDiff("yyyy",Now,BirthDay)<-140 or cdate(BirthDay)>date() Then
CheckCardId= "身份证输入错误!"
Exit Function
End If
If strMonth > 12 Or strDay > 31 Then
CheckCardId= "身份证输入错误!"
Exit Function
End If
Else
CheckCardId= "身份证输入错误!"
Exit Function
End If
Dim i, TotalmulAiWi
For i = 0 To 16
TotalmulAiWi = TotalmulAiWi + CInt(Mid(Ai, i + 1, 1)) * Wi(i)
Next
Dim modValue
modValue = TotalmulAiWi Mod 11
Dim strVerifyCode
strVerifyCode = arrVerifyCode(modValue)
Ai = Ai & strVerifyCode
CheckCardId = Ai
If Len(e) = 18 And e <> Ai Then
CheckCardId= "身份证号码输入错误!"
Exit Function
End If
End Function
response.write CheckCardId("528337194801020025") '''''''''这个不知是谁的身份证,我一试就出来了~~~~~~~~~哈哈

'''''这个如果返回的是输入的身份证,则表明正确,否则会提示出错...