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
using the flags
property.
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 valid
and invalid
events.
For an 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:
matchedIndex
An integer that contains the starting index in the input String of the match.matchedString
A String that contains the substring of the input String that matches the regular expression.matchedSubStrings
An Array of Strings that contains parenthesized substring matches, if any. If no substring matches are found, this Array is of length 0. Use matchedSubStrings[0] to access the first substring match.
See also:
EReg
Constructor
Variables
noExpressionError:String
Error message when there is no regular expression specifed. The default value is "The expression is missing."
noMatchError:String
Error message when there are no matches to the regular expression. The default value is "The field is invalid."