求解:(asp) 文章发布时候 怎样过滤限定字符

来源:百度知道 编辑:UC知道 时间:2024/06/08 05:11:05
我现在有一文章发布的页面,文本区域的代码是(部分代码):
<tr>
<td width="16%" valign="top">内    容:</td>
<td width="84%" valign="middle">
<textarea rows="6" name="t3" cols="43"></textarea></td>
</tr>

单击递交页面后 就回转到下个页面(部分代码):
<%if trim(request("gq"))="" then response.redirect "addmesg.asp?w=1&adwh=" &request("n")
if trim(request("t1"))="" then response.redirect "addmesg.asp?w=2&adwh=" &request("n")
if trim(request("t5"))="" then response.redirect "addmesg.asp?w=3&adwh=" &request("n")
if trim(request("t4"))="" then response.redirect "addmesg.asp?w=4&adwh=" &request("n")
if trim(request("t3"))="" then response.redirect "addmesg.asp?w=5&adwh=&q

noword="限制字符1|限制字符2|限制字符3"
'限制的字符,用|分开,可以无限个
requestt3=trim(request("t3"))
myarray=split(noword,"|") '|是上面的分割字符,可以用别的
for i=0 to ubound(myarray)
if instr(requestt3,myarray(i))>0 then
response.write "<script>alert('包含非法字符"+cstr(myarray(i))+",确认返回!');window.history.back();</script>"
'如果你要把非法字符修改并发布,则请使用下面的一句
requestt3=replace(requestt3,myarray(i),'要替换成的字符串')
end if
next

用replace函数,给出代码也不能直接用的。建议学一些ASP的基本知识吧