The RegExpValidator class uses a regular expression to validate a field. You can define a regular expression to the validator using expression property.
The RegExpValidator class uses a regular expression to validate a field. You can define a regular expression to the validator using expression property.The RegExpValidator class uses a regular expression to
validate a field. You can define a regular expression to the validator using
expression property. The validation will be successful if the field value
matches with the regular expression.
If the value does not match an error message occur.
The tag of RegExpValidator is <mx:RegExpvalidator>.
In this example you can see how we can use RegExpValidator.
|
<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"xmlns:s=" library://ns.adobe.com/flex/spark"xmlns:mx=" library://ns.adobe.com/flex/mx"minWidth=" 955" minHeight="600"><![CDATA[ import mx.controls.Alert;{ var result:RegExpValidationResult;resulttxt.text= "x"; for (var i:uint = 0; i < Obj.results.length; i++){ result = Obj.results[i]; resulttxt.text=resulttxt.text + result.matchedIndex + " " + result.matchedString;} } else{ resulttxt.text= "";} } ]]> </fx:Script> <fx:Declarations>source=" {regtxt}" property="text"flags=" g" expression="{regextxt.text}"invalid="Result(event)" trigger=" {btn}" triggerEvent="click"valid="Alert.show( 'Validation Successful'), Result(event);"/></s:Application> |
To view this page ensure that Adobe Flash Player version 10.0.0 or greater is installed.