The Validator class, the base class for all Flex validators, contains a required property that when set to true causes validation to fail when a field is empty. You use this property to configure the validator to fail when a user does not enter data in a required input field.
You typically call the validate() method to invoke a validator on a required field. This is often necessary because you cannot guarantee that an event occurs to trigger the validation– an empty input field often means that the user never gave the input control focus.
The following example performs a validation on a required input field:
<mx:TextInput id="inputA"/><?xml version=”1.0″?>
<!– validators\RequiredVal.mxml –>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml”>
<mx:StringValidator id=”reqV”
source=”{inputA}”
property=”text”
required=”true”/>
<mx:Button label=”Submit”
click=”reqV.validate();”/>
</mx:Application>



(+8)


