可以參考參考,順便記錄。
Function checkUniformNo(strUniformno)
If Len(strUniformno) > 0 Then
Dim objRegExp, i, arrayNum, intTotal, intTemp
Set objRegExp = New RegExp
With objRegExp
.Global = False
.IgnoreCase = True
.Pattern = "^[0-9]{8}$"
End With
arrayNum = Array(1,2,1,2,1,2,4,1)
If objRegExp.Test(strUniformno) = True Then
For i = 0 to Len(strUniformno) - 1
intTemp = Mid(strUniformno, i + 1,1) * arrayNum(i)
intTotal = intTotal + (Fix(intTemp / 10)) + (intTemp mod 10)
Next
If Not ((intTotal mod 10 = 0) Or ((intTotal Mod 10 = 9 And Mid(strUniformno,7,1) = 7))) Then
Response.Write "<script type=""text/javascript"">alert(""統一編號有誤,請再檢查一遍"");history.go(-1);</script>"
Response.End
End If
Else
Response.Write "<script type=""text/javascript"">alert(""統一編號有誤1,請再檢查一遍"");history.go(-1);</script>"
Response.End
End If
Set objRegExp = Nothing
End If
End Function
參考網址: http://herolin.twbbs.org/entry/is-valid-TW-company-ID/
沒有留言:
張貼留言