快精灵印艺坊 您身边的文印专家
广州名片 深圳名片 会员卡 贵宾卡 印刷 设计教程
产品展示 在线订购 会员中心 产品模板 设计指南 在线编辑
 首页 名片设计   CorelDRAW   Illustrator   AuotoCAD   Painter   其他软件   Photoshop   Fireworks   Flash  

 » 彩色名片
 » PVC卡
 » 彩色磁性卡
 » 彩页/画册
 » 个性印务
 » 彩色不干胶
 » 明信片
   » 明信片
   » 彩色书签
   » 门挂
 » 其他产品与服务
   » 创业锦囊
   » 办公用品
     » 信封、信纸
     » 便签纸、斜面纸砖
     » 无碳复印纸
   » 海报
   » 大篇幅印刷
     » KT板
     » 海报
     » 横幅

几个比较好用的ASP检查函数

因为比较简朴,我就不说什么了。一看就明白的!

Function ChkStr(InString)
If InString<>"" Then
InString=Replace(LCase(InString)," ","")
InString=Replace(LCase(InString),";","")
InString=Replace(LCase(InString),"\\\'","")
InString=Replace(LCase(Instring),"--","")
Instring=Replace(LCase(Instring),"%","")
InString=Replace(LCase(InString),"%20","")

InString=Replace(LCase(InString),"admin","")

InString=Replace(LCase(InString),"and","")
InString=Replace(LCase(InString),"or","")

InString=Replace(LCase(InString),"asc","")
InString=Replace(LCase(Instring),"chr","")
InString=Replace(LCase(InString),"mid","")
InString=Replace(LCase(InString),"len","")

InString=Replace(LCase(InString),"select","")
InString=Replace(LCase(InString),"insert","")
InString=Replace(LCase(InString),"delete","")
InString=Replace(LCase(InString),"update","")


ChkStr=InString
End If
End Function

Function CheckFileExt(FileExt)
Dim FileAccessExt,AccessExt
AccessExt="gif,jpg,jpeg,bmp,doc,txt,png"
FileAccessExt=Split(AccessExt,",")
For i=LBound(FileAccessExt) to UBound(FileAccessExt)
If LCase(FileExt)=LCase(FileAccessExt(i)) Then
CheckFileExt=True
Else
CheckFileExt=False
End If
Next
End Function

Function CheckStr(str,IsStr)
CheckStr=str
If IsStr And InStr(str,",")>0 Then
Call errmsg("提交字符中包含非法字符")
ElseIf (Not IsStr) And (Not IsNumeric(str)) Then
Call errmsg("提交不是数字型")
End If
End Function

Sub errmsg(str)
If Not IsNull(str) Then
Response.Write(str)&"&lt br &gt"
Call ASCpy()
Response.End() \\\'Very Improtan.Stop execute program.
End If
End Sub


Sub ASCpy()
Response.Write "<link href=\\\'Css/Maincss.css\\\' rel=\\\'stylesheet\\\' type=\\\'text/css\\\'>"
Response.Write "<div align=\\\'center\\\' class=\\\'Maincss\\\'>"
Response.Write("<Center>Error happed!<br>Please Contract ")
Response.Write("Name:<a href=\\\'mailto:jdqn@sjzu.edu.cn\\\' style=\\\'text-decoration:none\\\'>")
Response.Write("<font Color=red>AloneSword</font>")
Response.Write("</a>.<br>Thank you!!!</Center><br>")
Response.Write "<hr>Copyright &copy; By <a href=\\\'#\\\' style=\\\'text-decoration:none\\\'>建大网络</a> &#8482;<br>"
Response.Write "Last Modified:21/08/2004<br>"
Response.Write("Author:<a href=\\\'http://www.fcxx.net\\\' style=\\\'text-decoration:none\\\' target=\\\'_blank\\\'>AloneSword</a>")
Response.Write "</div>"
End Sub

小结:

最值得学习的还是response.End()的合理使用,异常的好。只要出现错误立刻终止程序的运行,不给后面的机会,保证数据的安全。
返回类别: 教程
上一教程: ASP与TXT组合设计程序的实例
下一教程: REMOTE SCRIPT文档(转载自微软)(六)

您可以阅读与"几个比较好用的ASP检查函数"相关的教程:
· 一个比较实用的ASP函数集合类
· 几个ASP好用的自定义函数
· 一个比较使用的ASP 函数集合类
· ASP中几个有用的函数
· 检查EMAIL地址的比较完善的正则表达式函数
    微笑服务 优质保证 索取样品