Saturday, February 2, 2013

Removing HTML tags in an input element.


Removing HTML tags in an input element.


index.html (Removing HTML in INPUT element).
<html>
<head>
<script>
var el = document.getElementById("in"); // or just another HTML DOM element
var text = el.value.replace(/<[^>]+>/g, "");
 document.getElementById("in").value=text;
</script>
</head>
<body>
<input id="in" value="<a>Subin</a>">
</body>
</html>
If the code above didn't worked try placing the script after the input element.
This is the script
 <script>
var el = document.getElementById("in"); // or just another HTML DOM element
var text = el.value.replace(/<[^>]+>/g, "");
 document.getElementById("in").value=text;
</script>

No comments:

Post a Comment

Leave the comments