html validation

liunx

Guest
Hi,<br />
I want to check if a given html has all the needed tags or not i.e. I have to do some sort of validation but by not using a standard validator. I have to write my own javascript code to get the code and test it. Any idea how to get the code in a function or a separate file to do any parsing or validation?<br />
<br />
Thanks.<!--content-->The best you can do is start from the head tag( i.e html tag does not allow id attribute but head tag does).<br />
Then in your function just to this.<br />
<head id="htmlHead"><br />
var html = document.getElementById("htmlHead").innerHTML ;<br />
<br />
T this point html varaible contains everything beyond the title element.<br />
and the same you can do with the body tag.<br />
<br />
cheers<br />
<br />
Khalid<!--content-->I don't think that you realize how big a task you have before you. HTML has quite a lot of rules about what elements can or must contain what elements and attributes. And to make things worse, there are eight different sets of rules recognized by the W3C. Your best bet is to do a JavaScript port of the W3C validator. Its source code can be found at <!-- m --><a class="postlink" href="http://validator.w3.org/source/">http://validator.w3.org/source/</a><!-- m -->.
 
Back
Top