asp trim()的问题

来源:百度知道 编辑:UC知道 时间:2024/06/24 13:50:07
if(trim(request.form("mcontent"))="") then
response.write("<script>alert('please input correct content');location.href=""javascript:history.go(-1)"";</script>")
end if

我的TRIM()可以去掉空格,但不能去掉回车,我做的留言板别人直接用回车也可以流,为什么
一楼的朋友的代码的意思是把trim()过的字符串判断长度,但回车符号还在,长度肯定还为1,永远也执行不到后面,我的目的是要去掉这个回车,TRIM()却去不掉,我试了你的代码还是不行,谢谢了,再帮我看看吧

小于N也不管用,你用2,我打2个回车就可以提交了,总之治标不治本,谢谢了

Server.HtmlEncode(request.form("mcontent"))
是把内容原样输出吗?即使是脚本或HTML代码?

replace(str,chr(10),"") 这个能解释下意思吗,而且我指的是回车,不是空格

留言板,应该是别人留什么都可以留的,TRIM没了空格,呵呵……什么信息都不让留,还做那做什么?
有病的人有的是,愿意留什么就留什么了。唉!
只要不攻击你就可以了。尽量避免他们提交代码伤害你就好了,给你个简单的:
If Len(request.form("mcontent"))<3 Then
response.write("<script>alert('信息能少于3个字符');location.href=""javascript:history.go(-1)"";</script>")
Else
Content = Server.HtmlEncode(request.form("mcontent"))
End If

然后写数据库就可以了,最简单的留言板,大致就这样。

Else

你看看这样,别人用回车还可不可以留

if(len(trim(request.form("mcontent")))<2) then
response.write("<script>alert('please input correct content');location.href=""javascript:history.go(-1)"";</script>")
end if

去掉空格的话可以这样来
replace(str,chr(10),"")
replace(str,chr(13),"")