JQuery to validate HTML in TextArea

I have a TextArea that allows the user to enter HTML, what I'm trying to do now is check the users HTML to make sure that it is XHTML.

Any ideas?

+6
jquery validation textarea
source share
2 answers

You can use the DOM Parser to find out if the content is XML.

See here .


SNIPPET:

if (window.DOMParser) { parser=new DOMParser(); xmlDoc=parser.parseFromString(text,"text/xml"); } else // Internet Explorer { xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async="false"; xmlDoc.loadXML(text); } 
+4
source share

I would suggest using regular expressions. Start with this post here.

I have not seen a jquery plugin that does exactly what you want, but I'm sure you can modify some existing validations.

0
source share

All Articles