I have a TextArea which allows the user to enter HTML, what I am now trying to do is to validate the users HTML to ensure it is XHTML.
Any ideas?
You can use a DOM Parser to see 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);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With