The RegExpValidator class lets you use a regular expression
to validate a field.
You pass a regular expression to the validator using the
expression property, and additional flags
to control the regular expression pattern matching
The validation is successful if the validator can find a match of the regular expression in the field to validate. A validation error occurs when the validator finds no match.
The RegExpValidator class dispatches the
invalid event, the event object is an instance
of the ValidationResultEvent class, and it contains an Array
of ValidationResult objects.
However, for a
valid event, the ValidationResultEvent
object contains an Array of RegExpValidationResult objects.
The RegExpValidationResult class is a child class of the
ValidationResult class, and contains additional properties
used with regular expressions, including the following:
matchedIndexAn integer that contains the starting index in the input String of the match.
matchedStringA String that contains the substring of the input String that matches the regular expression.
matchedSubStringsAn Array of Strings that contains parenthesized substring matches, if any. If no substring matches are found, this Array is of length 0. Use matchedSubStrings to access the first substring match.
The regular expression to use for validation.
The regular expression flags to use when matching.
Error message when there is no regular expression specifed. The default value is "The expression is missing."
Error message when there are no matches to the regular expression. The default value is "The field is invalid."