天枫常用的ASP函数封装如下

2019-04-02 00:19:55丽君

  Set Rep=Nothing
 End Function

 '****************************************************
 '函数名:CheckPassword
 '作  用:密码检验
 '参  数:str ----字符串
 '返回值:true无误,false有误
 '****************************************************
 Public Function CheckPassword(Str)
  Dim pass
  CheckPassword=true
  If Str <> "" Then
   Dim Rep
   Set Rep = New RegExp
   Rep.Global = True
   Rep.IgnoreCase = True
   '匹配字母、数字、下划线、点号
   Rep.Pattern="[a-zA-Z0-9_.]+$"
   Pass=rep.Test(Str)
   Set Rep=nothing
   If not Pass Then CheckPassword=false
   End If
 End Function 

 '****************************************************
 '函数名:CheckEmail
 '作  用:邮箱格式检测
 '参  数:str ----Email地址
 '返回值:true无误,false有误
 '****************************************************
 Public function CheckEmail(email)
     CheckEmail=true
  Dim Rep
  Set Rep = new RegExp
  rep.pattern="([.a-zA-Z0-9_-]){2,10}@([a-zA-Z0-9_-]){2,10}(.([a-zA-Z0-9]){2,}){1,4}$"
  pass=rep.Test(email)
  Set Rep=Nothing
  If not pass Then CheckEmail=false
 End function

'--------------信息提示----------------------------  
 '****************************************************
 '函数名:Alert
 '作  用:弹出对话框提示
 '参  数:msg   ----对话框信息
 '       gourl ----提示后转向哪里
 '返回值:无
 '****************************************************
    Public Function Alert(msg,goUrl)
  msg = replace(msg,"'","'")
    If goUrl="" Then
     goUrl="history.go(-1);"
  Else
   goUrl="window.location.href='"&goUrl&"'"
  End IF
  Response.Write ("<script language=""JavaScript"" type=""text/javascript"">"&vbNewLine&"alert('" & msg & "');"&goUrl&vbNewLine&"</script>")
  Response.End
 End Function