’******************************************
’ str1 允许的字符串列表
’ str2 外部输入字符串列表
’******************************************
Function isValid(str1,str2)
’Dim strText
isValid = False
For i = 1 to Len(Trim(str2))
If i = 1 Then
If (Mid(str2,i,1) = "_") Or (Mid(str2,i,1) = "-") Then
isValid = False
Exit For
End If
End If
If InStr(str1,Mid(str2,i,1)) > 0 Then
isValid = True
Else
isValid = False
Exit For
End If
Next
End Function
str1 = "0123456789"
if not isValid(str1,request("id")) Then
response.write "
Response.end
End if
’******************************************
’ str1 允许的字符串列表
’ str2 外部输入字符串列表
’******************************************
’ str1 允许的字符串列表
’ str2 外部输入字符串列表
’******************************************
Function isValid(str1,str2)
’Dim strText
isValid = False
For i = 1 to Len(Trim(str2))
If i = 1 Then
If (Mid(str2,i,1) = "_") Or (Mid(str2,i,1) = "-") Then
isValid = False
Exit For
End If
End If
If InStr(str1,Mid(str2,i,1)) > 0 Then
isValid = True
Else
isValid = False
Exit For
End If
Next
End Function
str1 = "0123456789"
if not isValid(str1,request("id")) Then
response.write "
警告!请不要尝试提交非法字符!你的IP已经被记录!
本页3秒后自动 返回
"
本页3秒后自动 返回
Response.end
End if
’******************************************
’ str1 允许的字符串列表
’ str2 外部输入字符串列表
’******************************************
本文介绍了一个用于验证外部输入字符串是否只包含指定字符集内的字符的VBScript函数。该函数通过遍历输入字符串并检查每个字符是否在允许的字符列表中来工作。如果发现非法字符,则会发出警告,并记录用户的IP地址。
801

被折叠的 条评论
为什么被折叠?



