The following is a very simple example of using jQuery to remove HTML Tags from your content:

<!DOCTYPEhtmlPUBLIC”-//W3C//DTD XHTML 1.0 Strict//EN””http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”&gt;

<html>

<head>

<title>Strip HTML</title>

$(document).ready(function () {

var htmlString = $(“#textbox1”).val();

/* replace escaped brackets with real ones */

var htmlString2 = htmlString.replace(/&(lt|gt);/g, function (strMatch, p1) {

return (p1 == “lt”) ? “”;

});

$(“#textbox2”).val(htmlString2);

/* strip text */

var htmlString3 = htmlString2.replace(/]+(>|$)/g, “”);

$(“#textbox3”).val(htmlString3);

});

</head>

<body>

    <inputtype=”text”id=”textbox1″name=”textbox1″style=”width:350px;height:40px;”value=”<br><strong>This is a test</strong><p>”/><br/>

    <inputtype=”text”id=”textbox2″name=”textbox2″style=”width:350px;height:40px;”value=””/><br/>

    <inputtype=”text”id=”textbox3″name=”textbox3″style=”width:350px;height:40px;”value=””/>

</body>

</html>

And here is the result:

Advertisements