asp表单检测

来源:百度知道 编辑:UC知道 时间:2024/05/28 10:17:37

表单提交文本内容如下:
今天是2009年3月24号.等等等等等......

怎样检测 文本内容里是否有非法的字词 如发票..M Y ,F L G 等等...

如果有就提示信息里有非字关键字.......

要求用asp语言

Function check()
dim tmp = Request.Form
dim arr = Array("发票","M Y","F L G")
For i = 0 to UBound(arr)
if instr(tmp,arr[i]) > 0 then
check = true
exit
end if
next i
check = false
end function

Function CheckStr(Str)
ErrStr=Array("发票","MY","FLG","&","+",";","@","!") '在这里写上你的非法字符
For i=0 to Ubound(ErrStr)
If Instr(Str,ErrStr(i)) > 0 then
ErrFlag = False
Exit For
Else
ErrFlag = True
End If
Next
CheckStr = ErrFlag
End Function

使用说明:
将以上代码放到你的页面中,
content=request.form("content")
if CheckStr(content)=false then
response.write("<script>alert('你输入的信息中含非法字符,如果你龟儿想攻击大爷的网站的话,大爷告诉你:门儿都没得!');history.back();</script>")
response.end()
end if
如果没有弹出框框,那就是合法的

这个比较简单,不过必须知道你需