Sample 'User Functions' File

Below is a sample 'user functions' file for the validator engine, which is a text file containing functions that customize validations. The 'User function' file can be specified in the Config File Options Page of the Validator Engine Options.

The Special Functions topic explains many of the functions that can be defined in the 'user functions' file.

The sample is meant to help you create your own 'user functions' file and is not meant to be used directly as a real 'user functions' file.

Sample 'User Functions' File Below

/*
 This function is called when the configuration is first loaded,
 and can be used to set up or change some additional options.
*/
function onConfigLoad() {
 // add words to exclude from the search engine keyword density message
 setValueString(21,"apple,orange");
 
 // recognize the following typefaces as "web-safe"
 setValueString(10,"Titillium","ubuntu-title","Bebas","Cantarell");
 
 // recognize the following typefaces as valid
 setValueString(11,"Titillium","ubuntu-title","Bebas","Cantarell");
}
//---------------------------------------------------------------------------
 
 
// exclude numbers and words ending in ".com" (case-insensitive)
function onKeywordDensityWord() {
 if matchRegEx("^\d+$",0,$okdw_word) { #okdw_exclude=true; }
 else if matchRegEx("\.com$",1,$okdw_word) { #okdw_exclude=true; }
}
//---------------------------------------------------------------------------
 
 
function onStartTag_h1() {
 #h1tagcounter++;
 Message(1,$MSG_MESSAGE,'This is "h1" element #'+$h1tagcounter);
}
//---------------------------------------------------------------------------
 
 
// display a warning message if "table" is used without a "summary" attribute
function onStartTag_table() {
 if !hasAtt("summary") {
  Message(1,$MSG_WARNING,'Missing "summary" attribute.');
 }
}
 
 
//---------------------------------------------------------------------------
function onStartTagFirst() {
 // if the DOCTYPE has not been set, generate an error if flag 180 is set
 if isFlagSet(180) {
  if DocTypeFlags&1024 {
   MessageEx(13,2011072901,#MSG_ERROR,'[180] Oops. No DOCTYPE was specified before the first start-tag.');
  }
  else {
   MessageEx(13,2011072902,#MSG_MESSAGE,'[180] Great! A DOCTYPE was used before the first start-tag.');
  }
 }
 else {
  MessageEx(13,2011072903,#MSG_MESSAGE,'[180] Check for DOCTYPE before first start-tag is disabled because flag 180 is not set.');
 } 
}
//---------------------------------------------------------------------------
 
 
function onStartValidation() {
 MessageEx(13,2011072900,"Starting the validation...");
}
//---------------------------------------------------------------------------
 
 
// When using the Quick Quote Attribute Values Tool, convert
// some characters to character references.
function onTool_QuoteAttVal_Value() {
 $attvalue=replaceStringCase($attvalue,'<','&lt;');
 $attvalue=replaceStringCase($attvalue,'"','&quot;');
 $attvalue=replaceStringCase($attvalue,'\'','&apos;');
}
//---------------------------------------------------------------------------