通過以下正則表達式來驗證
'================
'驗證信息是否合法(常用戶注冊)
'n--獲取類型
's--驗證字符
'================
Function g_ExStr(n,s)
IF IsNull(n) or n = "" Then Exit Function
Dim Reg_Ex,Ex_Str
g_ExStr = False
Set Reg_Ex = New RegExp
Select Case n
Case "Aug_Email" '驗證郵箱格式
Ex_Str = "^\w+((-\w+)|(.\w+))*@[A-Za-z0-9]+((.|-)[A-Za-z0-9]+)*.[A-Za-z0-9]+"
'Ex_Str = "^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
Case "Aug_Moble" '驗證手機號碼
Ex_Str = "^1[3|5][0-9]\d{4,8}"
Case "Aug_Cell" '驗證電話號碼
Ex_Str = "(^[0-9]{3,4}\-[0-9]{3,8})|(^[0-9]{3,8})"
Case "Aug_Number" '驗證是否為數(shù)字
Ex_Str = "^[0-9]+"
Case "Aug_China" '驗證是否為中文
Ex_Str = "^[\u0391-\uFFE5]+"
Case "Aug_UserName" '驗證用戶名只能為5-20位
Ex_Str = "^[A-Za-z0-9_]{5,20}"
Case Else
Ex_Str = "錯誤"
End Select
Reg_Ex.Pattern = Ex_Str
Reg_Ex.IgnoreCase = True
Reg_Ex.Global = True
Set Match = Reg_Ex.Execute(s)
IF Match.Count Then g_ExStr = True
End Function
IF g_ExStr("Aug_Email",request.form("email")) = False Then
Response.Write("<script language=""JavaScript"">alert(""E-mail can not be empty!"");history.go(-1);</script>")
response.end
end if