checkTagContents() (tick_24Validator Engine Only)

int checkTagContents(int $checktype[, int $flags[, int $msgid[, string $tagname1[, string $tagname2...]]]]);

$checktype

1 - check all (unless flag 8) $tagname1 elements to make sure their children consist only of $tagname2, $tagname3, etc. elements (and no other child elements), and returns 1 if so (unless a flag is used that specifies a different return value)

$flags

1 - display default error messages if needed

2 - $tagname1 tags must directly contain (as children) at least one of the allowed elements; if a message is generated due to this flag, then the message id used will be $msgid+1 unless $msgid is -1

4 - the $msgid is only for messages caused by flag 2 (1 will not be added to $msgid in this case); messages caused by flag 1 will not have a message ID

8 - check only the last child of the current node (good to use in end tag name programs)

16 - after $msgid, include a string to prepend to any displayed messages

32 - only check to make sure that $tagname1 tags directly contain at least one of the allowed elements (sets flag 2 and does not display error messages for tags used that are not listed as an allowed tag in the function parameters); returns 1 or greater (indicating which allowed element was used) if an allowed element is used

64 - $tagname1 tags must contain, in order, one of each of the other listed tags (New v9.9914)

128 - also allow script-supporting elements (per HTML5) (New v14.00)

256 - qualify messages as 'when the element is a child of its parent'; for example, instead of "The "noscript" element must...", use "The "noscript" element, when a child of "head", must..."

Default return value is 0

2 - returns 1 if the last child of the current node contains a "th" element (does not look in "td" elements), else returns 0 (or -1 if error); ONLY SUPPLY THE $checktype PARAMETER

3 - returns 1 if the last child of the current node contains only phrasing (inline) content, else 0 (or -1 if error); ONLY SUPPLY THE $checktype AND $flags PARAMETERS (New v14.00)

$flags

1 - display default error message if needed

2 - if a default error message is displayed, then include in the message that HTML5 documents also allow flow content (New v15.0110)

Good to use in the end tag programs for elements that can only contain phrasing content like "h1", "h2", "b", "p", "meter", "s", "span", "summary", etc.

4 - returns 1 if the last child of the current node is empty (inter-element whitespace is not allowed unless flag 2 is set), else 0 (or -1 if error); ONLY SUPPLY THE $checktype AND $flags PARAMETERS (New v14.00)

$flags

1 - display default error message if the current node is not empty

2 - allow inter-element whitespace

5 - returns 1 if the last child of the current node does not contain "header", "footer", sectioning content or heading content descendents, else returns 0 (or -1 if error); ONLY SUPPLY THE $checktype AND $flags PARAMETERS (New v14.00)

$flags

1 - display default error message(s) if disallowed content is found; will generate more than one error message if there's more than one disallowed element

2 - also disallow "address"

Good to use in end tag program for "dt"

6 - check the contents of a "label" element and generate appropriate messages; use 0 for $flags; ONLY SUPPLY THE $checktype AND $flags PARAMETERS (New v14.00)

7 - returns 1 if the last child of the current node does not have any interactive content descendents, else 0 (or -1 if error); ONLY SUPPLY THE $checktype AND $flags PARAMETERS (New v14.00)

$flags

1 - display default error message if needed

2 - allow the exceptions allowed by the "canvas" element (New v14.0107)

Good to use in the end tag programs for elements that cannot have interactive content descendents, like "button".

8 - returns 1 if the last child of the current node has no "rp" elements or if all the "rp" elements are used immediately before or immediately after an "rt" element, else 0 (or -1 if error); ONLY SUPPLY THE $checktype AND $flags PARAMETERS (New v14.00)

$flags

1 - display default error message(s) if needed; may generate more than one message

9 - returns 1 if "passes" this test: the last child of the current node does not contain only one table with a caption and one figcaption element, else returns 0 (or -1 if error); ONLY SUPPLY THE $checktype AND $flags PARAMETERS (New v14.00)

$flags

1 - display default warning message(s) if needed

Good to use in the end tag program for "figure".

10 - run in the end tag program for the "table" element to check its children for proper structure; returns 1 if everything is OK, else returns 0 (or -1 if error); use 0 for $flags; ONLY SUPPLY THE $checktype AND $flags PARAMETERS (New v14.00)

100 - returns 1 if the last child of the current node contains only text, else 0 (or -1 if error); ONLY SUPPLY THE $checktype, $flags, and $msgid PARAMETERS (New v14.00)

$flags

1 - display default error message if needed

2 - display a warning message using $msgid if empty or contains only whitespace (not displayed if returning 0)

4 - display an error message using $msgid if empty or contains only whitespace (not displayed if returning 0) (New v14.0205)

8 - return -2 if empty or contains only whitespace and would otherwise be returning 1 (New v14.0205)

Good to use in the end tag programs for elements that can only contain text like "option".

101 - returns 1 if the last child of the current node contains non-whitespace text, else 0 (or -1 if error); ONLY SUPPLY THE $checktype, $flags, and $msgid PARAMETERS (New v14.00)

$flags

not currently used

Good to use in the end tag programs for elements that should probably contain non-whitespace text like "caption".

$msgid - the message ID to use if any messages are generated; use -1 for no message ID

Example

The following is used in the end tag program (with flag 8) for "noscript" to make sure it only contains "link", "style", and "meta" elements and to generate the appropriate error message (with flag 1) if not (only if it is in a "head" section).

if isDescendentOf("head") { checkTagContents(1,265,-1,"noscript","link","style","meta"); }