且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用jquery/javascript在字符串中查找htmltag?

更新时间:2023-02-19 12:31:36

上面评论中给出的答复不考虑下面的html标签.

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");
}