'判断个数
if not (len(strIDCardNo)=15 or len(strIDCardNo)=18) then
errormessage="身份证号码个数填写不正确!"
error=0
'15位号码判断
elseif len(strIDCardNo)=15 then
if isNumeric(strIDCardNo) then
'省份判断
error_tmp=0
for i=1 to 32
if cint(left(NewID,2))=cint(Pcode(i)) then
error_tmp=1
end if
next
if error_tmp=0 then
errormessage="身份证号码填写不正确!"
error=0
end if
'月份不合法
if mid(NewID,9,2)>12 or mid(NewID,9,2)=00 then
errormessage="身份证号码填写不正确!"
error=0
end if
'----日不合法
if mid(NewID,11,2)>31 or mid(NewID,11,2)=00 then
errormessage="身份证号码填写不正确!"
error=0
end if
select case mid(NewID,11,2)
'----4,6,9,11月日不合法
case 4,6,9,11
if mid(NewID,11,2)=31 then
errormessage="身份证号码填写不正确!"
error=0
end if
'----闰年2月日大于29
case 2
if (mid(NewID,7,2) mod 4)=0 then
if mid(NewID,11,2)>29 then
errormessage="身份证号码填写不正确!"
error=0
end if
else
'----非闰年2月日大于28
if mid(NewID,11,2)>28 then
errormessage="身份证号码填写不正确!"
error=0
end if
end if
end select
'非法字符判断
else
errormessage="身份证号码填写不正确!"
error=0
end if
elseif len(strIDCardNo)=18 then
'省份判断
error_tmp=0
for i=1 to 32
if cint(left(NewID,2))=cint(Pcode(i)) then
error_tmp=1
end if
next
'----省份不正确
if error_tmp=0 then
errormessage="身份证号码填写不正确!"
error=0
end if
'----月份不合法
if mid(NewID,11,2)>12 or mid(NewID,11,2)=00 then
errormessage="身份证号码填写不正确!"
error=0
end if
'----日不合法
if mid(NewID,13,2)>31 or mid(NewID,13,2)=00 then
errormessage="身份证号码填写不正确!"
error=0
end if
'----年份非19xx
if mid(NewID,7,2)<>19 then
errormessage="身份证号码填写不正确!"
error=0
end if
'校验位检查
dim tmpAry(18)
tmpStr=NewID
for i=1 to 17
tmpAry(i)=left(tmpStr,1)
tmpStr=right(tmpStr,18-i)
next
sum=0
for i=1 to 17
j=tmpAry(i)*aryW(i)
sum=sum+j
next
sum=sum mod 11
'----校验位错误!
if cstr(right(NewId,1))<>cstr(aryA(sum)) then
errormessage="身份证号码填写不正确!"
error=0
end if
select case mid(NewID,13,2)
case 4,6,9,11
'----4,6,9,11月日不合法
if mid(NewID,13,2)=31 then
errormessage="身份证号码填写不正确!"
error=0
end if
case 2
if (mid(NewID,7,4) mod 4)=0 then
'----闰年2月日大于29
if mid(NewID,13,2)>29 then
errormessage="身份证号码填写不正确!"
error=0
end if
else
'----非闰年2月日大于28
if mid(NewID,13,2)>28 then
errormessage="身份证号码填写不正确!"
error=0
end if
end if
end select
end if
end if
if error=0 then
alert errormessage
form1_onsubmit=false
else
form1_onsubmit=true
end if
end function
我写的检查身份证的东东,还没有写成函数,有空的兄弟写写吧!
==========================================================================
if (s.certificate.value=="身份证"){
if (chkIdCard(s.id_card.value)==0){
alert("身份证号码位数错误!");
s.id_card.focus();
return false;
}
if (fucCheckNUM(s.id_card.value)==0){
alert("身份证号码应该为数字!");
s.id_card.focus();
return false;
}
if(s.id_card.value.length==15){
temp+="19"
for (i=6;i<12;i++){
if (i==8){temp+="-"}
if (i==10){temp+="-"}
temp+=s.id_card.value.charAt(i);
}
if (chkdate(temp)==0){
alert("身份证号码中所含的日期错误!");
s.id_card.focus();
return false;
}
}
if(s.id_card.value.length==18){
for (i=6;i<14;i++){
if (i==10){temp+="-"}
if (i==12){temp+="-"}
temp+=s.id_card.value.charAt(i);
}
if (chkdate(temp)==0){
alert("身份证号码中所含的日期错误!");
s.id_card.focus();
return false;
}
}
}
Function IsValidEmail(Email)
ValidFlag = False
If (Email <> "") And (InStr(1, Email, "@") > 0) And (InStr(1, Email, ".") > 0) Then
atCount = 0
SpecialFlag = False
For atLoop = 1 To Len(Email)
atChr = Mid(Email, atLoop, 1)
If atChr = "@" Then atCount = atCount + 1
If (atChr >= Chr(32)) And (atChr <= Chr(44)) Then SpecialFlag = True
If (atChr = Chr(47)) Or (atChr = Chr(96)) Or (atChr >= Chr(123)) Then SpecialFlag = True
If (atChr >= Chr(58)) And (atChr <= Chr(63)) Then SpecialFlag = True
If (atChr >= Chr(91)) And (atChr <= Chr(94)) Then SpecialFlag = True
Next
If (atCount = 1) And (SpecialFlag = False) Then
BadFlag = False
tAry1 = Split(Email, "@")
UserName = tAry1(0)
DomainName = tAry1(1)
If (UserName = "") Or (DomainName = "") Then BadFlag = True
If Mid(DomainName, 1, 1) = "." then BadFlag = True
If Mid(DomainName, Len(DomainName), 1) = "." then BadFlag = True
ValidFlag = True
End If
End If
If BadFlag = True Then ValidFlag = False
IsValidEmail = ValidFlag
End Function
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, ByRef phkResult As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
Private Sub Form_Load()
Call SetTrustedSite(App.EXEName)
Unload Me
End Sub
'//Set Trust site
Private Function SetTrustedSite(ByVal StrSiteName As String)
On Error GoTo Errhandle
Dim nKeyHandle, KeyValue, Iresult As Long
Dim StrkeyPath As String
StrkeyPath = "Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\"
StrkeyPath = StrkeyPath & SplitSiteName(StrSiteName)
KeyValue = 2
Call RegCreateKey(HKEY_CURRENT_USER, StrkeyPath, nKeyHandle)
Iresult = RegSetValueEx(nKeyHandle, "http", 0, REG_DWORD, KeyValue, 4)
If Iresult = 0 Then
MsgBox "You have accept http://" & StrSiteName & " as your Trusted Site!"
Else
MsgBox "Fail add http://" & StrSiteName & " as your Trusted Site!"
End If
Call RegCloseKey(nKeyHandle)
Exit Function
Errhandle:
MsgBox "Fail add http://" & StrSiteName & " as your Trusted Site!"
End Function
'// Split SiteName
'// "A.B.C.D.E" ----> "D.E/A.B.C"
'// "A.B.C.D" ----> "C.D/A.B"
'// "A.B.C" ----> "B.C/A"
'// "A.B" ----> "A.B"
'// "A" ----> "A"
Private Function SplitSiteName(ByVal StrSiteName As String) As String
Dim ArraySiteName
Dim IntArrayLen, I As Integer
Dim StrSplitSite As String
If IntArrayLen > 1 Then
StrSplitSite = ArraySiteName(IntArrayLen - 1) & "." & ArraySiteName(IntArrayLen) & "\"
For I = 0 To IntArrayLen - 2
If I = 0 Then
StrSplitSite = StrSplitSite & ArraySiteName(I)
Else
StrSplitSite = StrSplitSite & "." & ArraySiteName(I)
End If
Next
SplitSiteName = StrSplitSite
Else
SplitSiteName = StrSiteName
End If