How To Find A Htmltag In A String Using Jquery/javascript?
I have a text area in a page. If user try to give some html tags as a input and submit then i need to throw an error. How can i get this done using jquery/javascript? Could anyone
Solution 1:
Reply given in the above comment is not considering below html tags.
<html>,<body> and <head>
So this is how i implemented the requirement and it is working fine.
var textboxValue = document.getElementById("textbox").value;
var nonHtmlValue = textboxValue.replace(/<[^>]+>/g, '');
if(textboxValue!=nonHtmlValue)
{
alert("HTML is not allowed");
}
Post a Comment for "How To Find A Htmltag In A String Using Jquery/javascript?"