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 please help me with this ?
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 please help me with this ?
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");
}