驗證郵箱很多在js客戶端驗證了,但是那樣很容易被人破了,我們在伺服器上用asp進行驗證的話就應該沒有問題了。複製代碼代碼如下:
'********************************************
'函數名稱:IsValidEmail
'作用:檢查Email位址合法性
'參數:email ----要檢查的Email位址
'傳回值:True ----Email位址合法
' False ----Email地址不合法
'********************************************
Public Function IsValidEmail(Email)
Dim names, name, I, c
IsValidEmail = True
names = Split(Email, @)
If UBound(names) <> 1 Then IsValidEmail = False: Exit Function
為 Each name In names
If Len(name) <= 0 Then IsValidEmail = False:Exit Function
For I = 1 To Len(name)
c = LCase(Mid(name, I, 1))
If InStr(abcdefghijklmnopqrstuvwxyz_-., c) <= 0 And Not IsNumeric(c) Then IsValidEmail = False:Exit Function
Next
If Left(name, 1) = . Or Right(name, 1) = . Then IsValidEmail = False:Exit Function
Next
If InStr(names(1), .) <= 0 Then IsValidEmail = False:Exit Function
I = Len(names(1)) - InStrRev(names(1), .)
If I <> 2 And I <> 3 Then IsValidEmail = False:Exit Function
If InStr(Email, ..) > 0 Then IsValidEmail = False
End Function