HOW TO: Use user functions for better table structure

Post here if your topic is about CSS HTML Validator but doesn't fit in another forum.
Post Reply
User avatar
Albert Wiersch
Site Admin
Posts: 3822
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

HOW TO: Use user functions for better table structure

Post by Albert Wiersch »

You can use user functions in the Pro+ edition to generate warning messages if a table is missing explicit tags like <tbody>, <thead>, and <tfoot>.

To do this, create a text file (for this example we'll call it 'userfunctions.txt') and copy and paste the follow functions into it:

Code: Select all

function onStartTag_tbody() {
 if !isTagExplicit { MessageEx(5, 2024070100, MSG_WARNING, 'My User Functions', 'Implied <'+CurrentTagName+'> tag before this tag.'); }
}

function onEndTag_table() {
 if !hasChildElement('thead') { MessageEx(5, 2024070101, MSG_WARNING, 'My User Functions', 'No <thead> element found for this table.'); }
 if !hasChildElement('tfoot') { MessageEx(5, 2024070102, MSG_WARNING, 'My User Functions', 'No <tfoot> element found for this table.'); }
}
Next, specify this file (userfunctions.txt) in the Validator Engine Options in the 'Validator Engine > Config File' options page as a 'User functions' file. Press OK and, when asked, be sure to reload the configuration to load and enable the new user functions.

If everything is working correctly then, when appropriate, you should see the new validator warnings in a new message category called 'My User Functions' in the 'Grouped' tab of the Results Window.
Albert Wiersch, CSS HTML Validator Developer • Download CSS HTML Validator FREE Trial
Post Reply