asp敏感词汇过滤和字数判断,适用于留言/评论
代码:
Function ChkInvaildWord(InvaildWords,Words)
ChkInvaildWord = True
InvaildWord = Split(InvaildWords,"|")
inWords = LCase(Trim(Words))
For i = LBound(InvaildWord) To UBound(InvaildWord)
If InStr(inWords,InvaildWord(i)) > 0 Then
ChkInvaildWord = True
Exit Function
End If
Next
ChkInvaildWord = False
End Function
Function getStringLen(str)
On Error Resume Next
Dim l
Dim c
Dim i
Dim t
l = Len(str)
t = l
For i = 1 To l
c = Asc(Mid(str,i,1))
If c >= 128 Or c < 0 Then t = t + 1
Next
getStringLen = t
If Err.Number <> 0 Then Err.Clear
End Function
使用方法:
if ChkInvaildWord("测试|敏感",rf("pinglun")) then
Call alert_back("内容含有违规词,请修改后再提交!")
end if
if getStringLen(rf("pinglun")) < 3 then
Call alert_back("内容不足3字,请修改后再提交!")
end if
明月浩空》原创,转载请保留文章出处。
本文链接:https://blog.myhkw.cn/asp_chkInvaildword.html
版权声明:若无特殊注明,本文为《正文到此结束
百科情报站
尛熙
倪佳