<% Function del(Word,t1,t2) a = InStr(Word,t1) b = InStr(Word,t2) l=Len(Word)-b if a<=1 then c="" else c=Left(Word,a-1)end if if b<1 then b=a end if d = Right(Word,l) del=c & d End Functiontxt=request.form("txt") While InStr(txt,"<")>0 txt=del(txt,"<",">") WendWhile InStr(txt," ")>0 txt=del(txt," "," ") Wend %> <%=txt%>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新建网页 1</title>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function Del(Word) {
a = Word.indexOf("<");
b = Word.indexOf(">");
len = Word.length;
c = Word.substring(0, a);
if(b == -1)
b = a;
d = Word.substring((b + 1), len);
Word = c + d;
tagCheck = Word.indexOf("<");
if(tagCheck != -1)
Word = Del(Word);
return Word;
}
function Check() {
ToCheck = document.form.text.value;
Checked = Del(ToCheck);
document.form.text.value = Checked;
return false;
}
// End -->
</SCRIPT>
</head><body>
<form action="mailto:[email protected]" name=form onSubmit="return Check()">
<textarea cols="50" rows="6" name="text"></textarea>
<br>
<input type="submit" value="递交">
</form></body></html>
多谢!!!
但我是写在ASP脚本里边的。用不了Javascript函数……还有一个就是,去掉了之后,还有空白字符。能不能不要空白。
请朋友指点。
我还是看不懂这个原理。
6#:但我是写在ASP脚本里边的。 用不了Javascript函数……
document.form.text.value = Checked;
改成:
document.form.text.value = Checked.replace(/\n|\r|[ ]/g, '');--------
这段JS适用于前端过滤
Function del(Word,t1,t2)
a = InStr(Word,t1)
b = InStr(Word,t2)
l=Len(Word)-b
if a<=1 then c="" else c=Left(Word,a-1)end if
if b<1 then b=a end if
d = Right(Word,l)
del=c & d
End Functiontxt=request.form("txt")
While InStr(txt,"<")>0
txt=del(txt,"<",">")
WendWhile InStr(txt," ")>0
txt=del(txt," "," ")
Wend
%>
<%=txt%>