There mey be situations where you need to remove all the HTML tags in a text. You can use Javascript Regex to to achove the desired result as displayed below.
<html>
<head>
<script type="text/javascript">
function replacetags(){
var html = /(<([^>]+)>)/gi;
for (i=0; i < arguments.length; i++)
arguments[i].value=arguments[i].value.replace(html, "")
}
</script>
</head>
<body>
<form name="form1">
<textarea class="comment" name="comments" id ="comments" rows=5 cols=50></textarea><br>
<input type="button" value="Remove Tags" onClick="replacetags(this.form.comments)">
</form>
</body>
</html>
<html>
<head>
<script type="text/javascript">
function replacetags(){
var html = /(<([^>]+)>)/gi;
for (i=0; i < arguments.length; i++)
arguments[i].value=arguments[i].value.replace(html, "")
}
</script>
</head>
<body>
<form name="form1">
<textarea class="comment" name="comments" id ="comments" rows=5 cols=50></textarea><br>
<input type="button" value="Remove Tags" onClick="replacetags(this.form.comments)">
</form>
</body>
</html>
No comments:
Post a Comment