int checkStringEx(int $flags, int $mode, string $string)

Use this function to perform various checks on a string. Some checks only work in the validator engine and thus do not work in Batch Wizard user functions.

$flags - can be added together; the $flags value depends on $mode so see the values for $mode below for available $flags; if a $mode does not say anything about $flags, then the $flags value is not used and should be 0.

$mode - can not be added together

1 - return TRUE if $string is a valid charset like "iso-8859-1"; see also mode 32 (Validator Engine Only)

2 - return TRUE if $string ends with a comma (disregarding trailing HTML5 space characters) (New v5.0200)

3 - return TRUE if $string appears to be a valid "lang" attribute value; $flags below (Validator Engine Only; New v5.4910)

1 - set $checkstringex3append to a suggested message to append to any error message

4 - return TRUE if $string begins with a '#' character (disregards preceding HTML5 space characters) (New v5.4910)

5 - return TRUE if $string contains two or more adjacent hyphens (use for checking comments; excludes beginning "!--" and ending "--", returns FALSE if $string begins with "!--#"); if returns TRUE then use getLocation(7,0) to get location of hyphens (Validator Engine Only; New v5.4910)

6 - return TRUE if $string ends in "--" followed by one or more HTML5 space characters (New v5.4910)

7 - return the number of words in $string (New v5.4930)

8 - return the number of repeated words/phrases given a comma separated list in $string; a list of repeated words/phrases is stored in $repeatedlist; the number of "empty" words is stored in $numemptywords ; new in v16.02(New v5.4940)

9 - returns TRUE if $string is a percent (New v5.4940)

10 - returns TRUE if $string contains only digits 0-9 (must contain at least one digit); $flags below (New v5.5100)

1 - allow leading HTML5 space characters

2 - allow trailing HTML5 space characters

4 - allow an optional preceeding '-' character

8 - require preceeding '-' character

16 - allow zero or one '.' characters

32 - require one '.' character

64 - allow an optional ending '%' character

128 - require ending '%' character

256 - instead of returning TRUE or FALSE, return one of following values

>=0 - value is OK

<0 - value is NOT OK

1 - value is a percent >100% (only if flag 512 set)

-1 - miscellaneous reason why value is not OK

-2 - misplaced or multiple '-' characters

-3 - multiple '.' characters

-4 - missing required '-' character

-5 - missing required '.' character

-6 - missing required '%' character

-7 - contains unallowed character or bad format

-8 - contains no digits (must contain at least 1)

512 - use with flag 256 to allow a return value of 1

11 - returns TRUE if $string contains only whitespace characters (one or more) and is not empty; see also 33, 42

12 - returns TRUE if $string is an index page (such as "index.htm", "index.html", "index.php", "index.asp") or if $string ends in a "/" followed by an index page

1 - if returning TRUE, then create variables $checkstringex12docname (contains "index.htm", "index.php", etc) and $checkstringex12recommendedurl (contains the recommended replacement URL)

13 - returns TRUE if $string contains a semicolon and period but no comma between two '@' characters (used for checking mailto links with multiple email addresses that could incorrectly be separated with semicolons instead of commas)

14 - returns TRUE if $string contains optional whitespace followed by optional digits (0-9) followed by optional whitespace followed by a CSS length unit; if returns TRUE, then the length unit is stored in $checkstringex14unit

15 - returns TRUE if $string appears to contain mismatched double or single quotation marks

1 - only check if value is <=100 characters

16 - returns TRUE if $string appears to contain improper backslashes instead of forward slashes (use for checking links)

17 - returns TRUE if $string appears to contain an improper double slash sequence (use for checking links)

18 - returns the number of commas in $string

19 - returns TRUE if $string is recognized as a web-safe typeface; if there are no recognized web-safe typefaces (if the list of recognized web-safe typefaces has been cleared), then will always return TRUE (Validator Engine Only; New v8.00)

20 - (Validator Engine Only) checks a comma separated list of typefaces in $string and returns FALSE if any of them are not recognized as "web-safe", which means that they may not be available on a significant number of browsers; else returns TRUE; if returns FALSE, then a list of the unrecognized typefaces is available in $checkstringex20list (with $checkstringex20listnum containing the number of typefaces in the list) and a complete list (including ignored typefaces) is available in $checkstringex20list2 (with $checkstringex20list2num containing the number of typefaces in the list).
 
In v8.9950 and above, if not all the typefaces are web-safe, then $checkstringex20unknownlist is also set with a list of unrecognized typeface names. $checkstringex20unknownlistnum contains the number of typefaces listed in $checkstringex20unknownlist.
 
In v10.0146 and above, if not all the typefaces are web-safe, then $checkstringex20numwebsafe is also set with the number of recognized web-safe typeface names, not including the generic font family keywords (like serif, sans-serif, monospace, etc.).
 
In v10.9912 and above, $checkstringex20extrainfo is also set with extra information about the listed typefaces, if it is available (if not available then it is empty).
 
NOTE: Once a typeface is recognized as not being web-safe and the number of recognized web-safe typefaces is 0, the typeface is ignored in further calls to this function for the duration of the validation. This is to prevent the same typeface (when used multiple times) from generating more than one validator message. You can add to the recognized list of web-safe typefaces using setValueString(10,typeface name) in the onConfigLoad() function. $flags below

1 - do not consider ignored typefaces from previous calls when returning TRUE or FALSE

2 - do not use; this flag used internally

21 - (Validator Engine Only) checks a comma separated list of typefaces in $string and returns FALSE if there are any unrecognized typefaces or if typefaces from more than one family were specified. If returns FALSE, then sets $checkstringex21msg with the text of a message to display, $checkstringex21numunrec with the number of unrecognized typefaces, $checkstringex21msgtype with the recommended message type (regular message if there were no unrecognized typefaces or a warning message type if there were unrecognized typefaces), and (in v9.0192 and later) $checkstringex21msgid with a recommended message ID. NOTE: Once a typeface is not recognized, it is ignored in further calls to this function for the duration of the validation. This is to prevent the same typeface being used multiple times from generating more than one validator message about it. You can add to the recognized list of typefaces using setValueString(11,typeface name) in the onConfigLoad() function. $flags below

2 - do not use; this flag used internally

22 - returns TRUE if $string contains a Sitestepper variable and Sitestepper integration is both on and supported in the edition being used (supported in std/pro editions) (Validator Engine Only; New 8.0200)

23 - returns TRUE if $string appears to be a link that can be passed to the link checker (preceding HTML5 space characters are ignored) (New 8.9910)

24 - returns TRUE if $string is a recognized typeface name (Validator Engine Only; New 8.9950)

1 - do not remove style (like "regular" or "italic"), weight (like "bold" or "black"), and condensed (like "condensed" and "extra condensed") names from the end of the font name when considering if the typeface is recognized (New v16.0305)

25 - (Validator Engine Only) checks a comma separated list of typefaces in $string and returns FALSE if there is a possible issue with CLF 2.0 compliance. If returns FALSE, then sets $checkstringex25msg with the text of a message to display, $checkstringex25numunrec with the number of possibly incompliant typefaces, $checkstringex25msgtype with the recommended message type, and $checkstringex25msgid with a recommended message ID. NOTE: Once a typeface is not recognized, it is ignored in further calls to this function for the duration of the validation. This is to prevent the same typeface being used multiple times from generating more than one validator message about it. You can add to the recognized list of typefaces using setValueString(11,typeface name) in the onConfigLoad() function. $flags below

2 - do not use; this flag used internally

26 - returns an int representing the color in $string; works with colornames and colors in the format #RRGGBB; ignores preceding HTML5 space characters; returns -1 if fails (Validator Engine Only; New 9.9910)

27 - returns an int based on the value of $string; for use with "input" elements to represent the value of the "type" attribute as an integer (set $string to the value of the "type" attribute); case-insensitive; runs program 65 (with flag 1) if it's an HTML5 control value and the program is running in an attribute or attribute value program (Validator Engine Only; New v9.9914)

set flag 1 to NOT run program 65 (New v9.9927)

set flag 2 to return 4 (the default or fallback) if the type is unrecognized (New v14.00)

return values: 0-(unknown), 1-image, 2-file, 3-textarea, 4-text (default), 5-checkbox, 6-radio, 7-password, 8-hidden, 9-submit, 10-reset, 11-button, HTML5: 12-search, 13-tel, 14-url, 15-email, 16-datetime, 17-date, 18-month, 19-week, 20-time, 21-datetime-local, 22-number, 23-range, 24-color

28 - returns TRUE if the CSS property $string was used in the value of the "style" attribute else returns FALSE; always returns FALSE if style checking is not enabled; forces style checking of the "style" attribute if style checking is enabled (Validator Engine Only; New v9.9927)

29 - returns TRUE if $string contains only recognized values for the "rel" attribute of the "link" element (separated by HTML5 space characters; case-insensitive); else returns FALSE and sets $checkstringex29badlist with a quoted list of the unrecognized values, $checkstringex29badlistnum with the number of unrecognized values, and (in v10.9944+) $checkstringex29badmsgappend with a suggested string to append to any error message (Validator Engine Only; New v9.9933)

30 - returns TRUE if $string contains at least one U+000A LINE FEED (LF) or U+000D CARRIAGE RETURN (CR) character (New v10.9921)

31 - returns TRUE if $string contains any HTML5 space characters, not considering any preceding and trailing space characters (New v10.9923)

32 - like 1, but also returns true if $string contains any collapsed PHP, ASP, etc. code (Validator Engine Only; New v10.9923)

33 - returns TRUE if $string is empty or contains only whitespace characters; see also 11, 42, and $var.isEmpty2() (New v10.9923)

34 - returns an int based on the value of $string; for use with WAI-ARIA "role" attributes to represent the value of the attribute as an integer (set $string to the value of the "role" attribute); case-insensitive (Validator Engine Only; New v10.9926)

return values: 0-(unknown), 1-alert, 2-alertdialog, 3-application, 4-article, 5-banner, 6-button, 7-checkbox, 8-columnheader, 9-combobox, 10-complementary, 11-contentinfo, 12-definition, 13-dialog, 14-directory, 15-document, 16-form, 17-grid, 18-gridcell, 19-group, 20-heading, 21-img, 22-link, 23-list, 24-listbox, 25-listitem, 26-log, 27-main, 28-marquee, 29-math, 30-menu, 31-menubar, 32-menuitem, 33-menuitemcheckbox, 34-menuitemradio, 35-navigation, 36-note, 37-option, 38-presentation, 39-progressbar, 40-radio, 41-radiogroup, 42-region, 43-row, 44-rowgroup, 45-rowheader, 46-search, 47-separator, 48-scrollbar, 49-slider, 50-spinbutton, 51-status, 52-tab, 53-tablist, 54-tabpanel, 55-textbox, 56-timer, 57-toolbar, 58-tooltip, 59-tree, 60-treegrid, 61-treeitem; new ARIA 1.1 roles supported in v15.9916+: 62-cell, 63-none, 64-searchbox, 65-switch, 66-table, 67-text

35 - returns TRUE if $string is a valid HTML5 ID token (at least one character and no HTML5 space characters); see also checkString(8) (New v11.0043)

36 - returns TRUE if $string begins with a letter (A-Z or a-z) and consists of the following characters: (A-Z), (a-z), (0-9), hyphens (-), and underscores (_); this is based on the HTML 4.01 specification for the valid characters of ID and NAME tokens but excludes the possibly problematic period (.) and colon (:) characters (New v11.0043)

37 - returns TRUE if $string is a valid value for a "link" element's "sizes" attribute, else returns FALSE and sets $checkstringex37badlist (New v11.0114)

38 - returns TRUE if $string appears to use the document.write() or document.writeln() function (New v11.9915)

39 - returns TRUE if $string appears to be a valid email address; if returning FALSE, then sets 1) $checkstringex39details with details about the incorrect syntax. See also checkString(512). NOTE: Always returns TRUE if email address syntax checking has been disabled. (Validator Engine Only; New v11.9942)

40 - returns TRUE if $string appears to be a proper HTML4 "multi-length-list", else returns FALSE; good for checking the "cols" and "rows" attributes for "frameset" (Validator Engine Only; New v12.0033)

41 - returns TRUE and sets $checkstringex41 to the function name if $string appears to be a function call (Validator Engine Only; New v12.0036)

42 - returns TRUE if $string is empty or contains only whitespace or the non-breaking space (&nbsp;) characters; see also 11, 33, and $var.isEmpty2() (New v14.00)

43 - returns TRUE if $string is a case-insensitive match for "text/html;" followed by any number of optional space characters, followed by "charset=", followed by the character encoding name; use for "meta" elements with http-equiv="content-type" (New v14.00)

44 - returns TRUE and sets $checkstringex44time if $string is a case-insensitive match for 1) a valid non-negative integer or 2) a valid non-negative integer, followed by a ";" character, followed by one or more space characters, followed by "URL=", followed by a URL that does not start with a quotation character; use for "meta" elements with http-equiv="refresh" (New v14.00)

45 - returns TRUE if $string is successfully parsed as a serialized Content Security Policy for use in a "meta" tag and no potential problems are detected, else returns FALSE and sets $checkstringex45details (Validator Engine Only; New v16.0104)

$checkstringex45details.checkmsgtext - the details of the potential problems that were detected as a text string

$checkstringex45details.checkmsgtype - the message type recommended for the potential problems that were detected (MSG_ERROR if one or more potential problems are considered more serious, else MSG_WARNING)

46 - like 45 but the serialized Content Security Policy is considered to be for use in an HTTP header and sets $checkstringex46details instead of $checkstringex45details (Validator Engine Only; New v16.0104)

50 - returns TRUE if $string is recognized as a valid name (case-insensitive) for the "name" attribute for the "meta" element, else returns FALSE; in v15+ allows a few extra meta names if not in standards compliant mode (Validator Engine Only; New v14.00)

51 - returns TRUE if $string is recognized as a failed name (case-insensitive) for the "name" attribute for the "meta" element, else returns FALSE (Validator Engine Only; New v14.00)

52 - returns TRUE if $string is recognized as a valid pragma directive (case-insensitive) for the "http-equiv" attribute for the "meta" element, else returns FALSE (Validator Engine Only; New v14.00)

53 - returns TRUE if $string appears to be an absolute URL (Validator Engine Only; New v14.00)

54 - returns TRUE if $string appears to be a valid global date and time string per HTML5 (or if flag 1 is set and the string contains script); else returns FALSE and sets $checkstringex54details (Validator Engine Only; New v14.00)

55 - returns TRUE if $string appears to be a valid date string per HTML5 (or if flag 1 is set and the string contains script); else returns FALSE and sets $checkstringex55details (Validator Engine Only; New v14.00)

56 - returns TRUE if $string appears to be a valid month string per HTML5 (or if flag 1 is set and the string contains script); else returns FALSE and sets $checkstringex56details (Validator Engine Only; New v14.00)

57 - returns TRUE if $string appears to be a valid week string per HTML5 (or if flag 1 is set and the string contains script); else returns FALSE and sets $checkstringex57details (Validator Engine Only; New v14.00)

58 - returns TRUE if $string appears to be a valid time string per HTML5 (or if flag 1 is set and the string contains script); else returns FALSE and sets $checkstringex58details (Validator Engine Only; New v14.00)

59 - returns TRUE if $string appears to be a valid local date and time string per HTML5 (or if flag 1 is set and the string contains script); else returns FALSE and sets $checkstringex59details (Validator Engine Only; New v14.00)

60 - returns TRUE if $string appears to be a valid floating-point number per HTML5 (or if flag 1 is set and the string contains script); else returns FALSE (Validator Engine Only; New v14.00)

61 - [see also 69] returns TRUE if $string appears to be a valid simple color per HTML5 (or if flag 1 is set and the string contains script); else returns FALSE (Validator Engine Only; New v14.00)

62 - returns TRUE if $string appears to be a valid "datetime value" of a "time" element per HTML5 (or if flag 1 is set and the string contains script); else returns FALSE (Validator Engine Only; New v14.00)

63 - returns TRUE if $string appears to be a valid date string with optional time per HTML5 (or if flag 1 is set and the string contains script); else returns FALSE and sets $checkstringex63details (Validator Engine Only; New v14.00)

64 - returns TRUE if $string appears to be a crawler user-agent name like "googlebot", "robots", "msnbot", etc.; $flags below (New v14.00)

1 - limit to known Google crawlers only

65 - returns TRUE if $string passes the available checks for a tel URI that starts with "tel:", else returns FALSE and sets $checkstringex65details (Validator Engine Only; New v14.00)

66 - returns TRUE if $string passes the available checks for an sms URI that starts with "sms:", else returns FALSE and sets $checkstringex66details (Validator Engine Only; New v14.00)

67 - returns TRUE if $string passes the available checks for the content of a "viewport" meta tag, else returns FALSE and sets $checkstringex67details

68 - returns FALSE if $string is a case-insensitive (but not case-sensitive) match for a valid name for the "name" attribute when it should match case-sensitively and sets $checkstringex68name to the name that should be used (Validator Engine Only; New v15.00)

69 - returns TRUE if $string appears to be a valid color (see flags) ; else returns FALSE (Validator Engine Only; New v16.04)

1 - return TRUE if $string contains script

2 - return TRUE if $string appears to be a simple color per HTML5

4 - return TRUE if $string appears to be a valid color in rgb() format

70 - returns TRUE if $string passes the available checks for the content of a "format-detection" meta tag, else returns FALSE and sets $checkstringex70details (Validator Engine Only; New v16.0306)

80 - returns TRUE if $string is a recognized audio Internet media type (MIME type); else returns FALSE (Validator Engine Only; New v15.00)

81 - returns TRUE if $string is a recognized image Internet media type (MIME type); else returns FALSE (Validator Engine Only; New v15.00)

82 - returns TRUE if $string is a recognized video Internet media type (MIME type); else returns FALSE (Validator Engine Only; New v15.00)

$string - the string to check

The default return value is 0 (FALSE) unless it is changed due to a valid mode.

See also the older function checkString()