笨朱先行
我的工作,学习,生活,作品,收藏,人生……
导航
首页
相册
标签
搜索
留言
管理
Where am I?
文章搜索:
正文
ASP身份证验证函数(修正版)
(2008-8-6 18:25) Tags:
网上流传着身份证验证函数,但是如果身份证效验码是x的话,会提示类型不匹配。
经过我检查最终修复了下,可以正常使用。具体函数如下:
Function IDCheck(e) dim arrVerifyCode,Wi,Checker,BirthDay IDCheck = true 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 'IDCheck= "身份证号共有 15 码或18位" IDCheck = 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 'IDCheck= "身份证除最后一位外,必须为数字!" IDCheck = False 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 'IDCheck= "身份证输入错误!" IDCheck = False Exit Function End If If strMonth > 12 Or strDay > 31 Then IDCheck = False 'IDCheck= "身份证输入错误!" Exit Function End If Else 'IDCheck= "身份证输入错误!" IDCheck = False 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 Ai = Ucase(Ai) e = Ucase(e) If Len(e) = 18 And e <> Ai Then 'IDCheck= "身份证号码输入错误!" IDCheck = False Exit Function End If End Function
发布:cs99619 | 分类:
ASP资料.net
| 评论:0 | 引用:0 | 浏览:
前一篇: ASP在写入数据库的时候引号和逗号的处理方式
后一篇: 很久没有写日志了
评论
发表
名称(*)
邮箱
网站链接
验证(*)
正文(*)(留言最长字数:1000)
记住我,下次回复时不用重新输入个人信息
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。
博主
留言给我
文章总数:642
评论总数:349
浏览总数:491651
留言总数:12
网站分类
心情日志.net
(113)
杂七杂八.net
(89)
精品收藏.net
(85)
ASP资料.net
(73)
智慧人生.net
(47)
大话网络.net
(46)
网页制作.net
(43)
原创作品.net
(36)
应用技巧.net
(30)
网络系统.net
(21)
社会观察.net
(13)
IT资讯.net
(10)
生活保健.net
(9)
平面设计.net
(7)
办公设备.net
(7)
Fireworks.net
(5)
办公软件.net
(3)
PHP资料.net
(2)
加密解密.net
(1)
医药软件.net
(2)
赞助商广告
最近发表
Powered By
Z-Blog
|
ICP备案号:
粤ICP备05077418号
Copyright 2007-2008
www.F6n.net
Some Rights By Joe.