onMessageID_(msgid)()

Replace (msgid) with the actual message ID. This function is called when a message is generated with the specified message ID. For example, use the function name onMessageID_1020715192 if you want the function to be called when a message with message ID 1020715192 is being generated. Messages with no message ID are treated as having a message ID of 0 so that onMessageID_0() will be called. This function can be used to cancel a message or to change it. (New v10.9912)

$omid_cancel - set this to true to cancel the message

$omid_msgid - the message ID of the validator message that is being generated (can be changed)

$omid_msgtext - the message text of the validator message that is being generated (can be changed)

$omid_msgtype - the message type of the validator message that is being generated (can be changed)

NOTE: This function is called before the message ID configuration is checked.

Be careful not to create infinite recursion problems by causing messages to be generated in this function which will then call this function again (be especially careful when using onMessageID_0()).

In v15 and above, a message with no message ID will cause onMessageID_0() to be called and $omid_msgid will be -1.

Example 1:

This simple example cancels any message with a message ID of 2013103103.

function onMessageID_2013103103() {
 $omid_cancel=true;
}

Example 2:

Let's say that you have this HTML: <meta name="customnamevalue" content="customcontent">

... and it's causing this validator message: The name "customnamevalue" specified by the "name" attribute is not a recognized metadata name. Visit https://www.w3.org/TR/html52/document-metadata.html#standard-metadata-names and https://wiki.whatwg.org/wiki/MetaExtensions for more information.

...and the message's ID is 2013070902. You can get the message ID in the Results Window of the editor by right-clicking on the validator message and hovering the mouse over the Message Options submenu in the context menu. The message ID will then be displayed in the status bar.

The following user function can be used to cancel this message:

function onMessageID_2013070902() {
 if stripos($omid_msgtext,'"customnamevalue"')>=0 {
  $omid_cancel=true;
 }
}

Example 3:

If you have a custom tag or element named "MyTag:cond" and you want to ignore all messages that mention the tag then you can use something like this for messages with no message ID:

function onMessageID_0() {
if (strpos($omid_msgtext,'MyTag:cond:')>=0) {
 $omid_cancel=true;
 }
}

And for the messages with a message ID (2017112100 for this example) that you want to ignore (you can repeat this function for other message IDs):

function onMessageID_2017112100() {
if (strpos($omid_msgtext,'MyTag:cond:')>=0) {
 $omid_cancel=true;
 }
}