Search

Custom Search
03
Dec
08

Enabling and disabling a validator in Flex

The Validator.enabled property lets you enable and disable a validator. When the value of the enabled property is true, the validator is enabled; when the value is false, the validator is disabled. When a validator is disabled, it dispatches no events, and the validate() method returns null.
For example, you can set the enabled property using data binding, as the following code shows:
Code Samples:

<?xml version="1.0"?>

<!-- validators\EnableVal.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">

<mx:ZipCodeValidator id="zcVal"

source="{inputA}"

property="text"

required="true"

enabled="{enableV.selected}"/>

<mx:TextInput id="inputA"/>

<mx:TextInput/>

<mx:CheckBox id="enableV"

label="Validate input?"/>

</mx:Application>

(In this example, you enable the validator only when the user selects the CheckBox control.) 

Another Great story?

Get Adobe Flash playerPlugin by wpburn.com wordpress themes