Legacy platform

Defining error messages

You can define error messages on each regular expression to show the context sensitive error.

The error messages are localizable bundle entries defined in the various bundle file. For example,

<RegularExpressions>
   <RegularExpression id="dates" javaPattern="^[a-zA-Z0-9]*$"
      jsPattern="^[a-zA-Z0-9]*$"  whitelistErrorMsg="only_alphanumeric_chars_allowed" 
      blacklistErrorMsg="alphanumeric_chars_not_allowed"/> 
</RegularExpressions>

and in the bundle.properties file, add the following entry:

only_alphanumeric_chars_allowed={1} must contain only alphanumeric characters. 
alphanumeric_chars_not_allowed={1} must not contain any alphanumeric characters.

In this case, If the regular expression dates fails in input validation, the error string defined in the bundle keys only_alphanumeric_chars_allowed or alphanumeric_chars_not_allowed is displayed as error message. The name of the input being validated will be used as the second message formatter. The first message formatter is the regular expression.

Note: If whitelistErrorMsg and/or blacklistErrorMsg attribute are not defined, the default error messages are displayed.