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

2019-01-13 12:34:05王振洲

 '****************************************************
 '函数名: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

    '****************************************************
 '函数名:GoBack
 '作  用:错误信息提示
 '参  数:str1   ----信息提示标题
 '       str2   ----信息提示内容
 '       isback ----是否显示返回
 '返回值:无
 '****************************************************
 Public Function GoBack(Str1,Str2,isback)
  If Str1="" Then Str1="错误信息"
  If Str2="" Then Str2="请填写完整必填项目"
  If isback="" Then 
   Str2=Str2&" <a href=""javascript:history.go(-1)"">返回重填</a></li>"
  else
   Str2=Str2
  end if
  Response.Write"<div style=""margin-left:5px;border:1px solid #0066cc;width:98%""><div style=""height:22px;font-weight:bold;color : white;font-size:14px;background:#799AE1;background:url(images/th.gif);;text-align:left;line-height:20px;padding:3px;"">"&Str1&" </div><div style=""line-height:50px;background:#F7F7F7;vertical-align:middle;font-size:14px;width:100%""><div  style=""color:red;font:50px/50px 宋体;float:left;width:5%"">×</div><div  style=""margin-top:8px;float:right;width:90%;text-align:left;padding-left:3px;"">"&str2&"</div></div></div>"
  response.end
 End Function