【转】利用 正则表达式 过滤掉 textarea ,textbox里的html标签

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> 正则表达式</TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!--
function stripHTML()
{
var re = /(<([^>]+)>)/gi; //正则表达式
for(i=0;i<arguments.length;i++)
arguments[i].value
= arguments[i].value.replace(re,"");

}
//-->
</SCRIPT>
</HEAD>
<BODY>
<form name ="myform">
<textarea name="remove" rows=10 cols=30 id="remove">
<p>javascript 过滤掉html标签</p>
<p>利用正则表达式</p>
</textarea><br />
<input type="button" value="Remove HTML Tags" onclick="stripHTML(this.form.remove)">
</form>
</BODY>
</HTML>
转载自:http://www.hscripts.com/scripts/JavaScript/remove-html-tag.php
posted @ 2011-03-23 13:43  qandq  阅读(578)  评论(0编辑  收藏  举报