HTML/CSS Service

Enabling and disabling a validator in Flex

Category: Flex Examples, Flex Samples, flex tutorials    |    2,429 views

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.) 

Share/Save/Bookmark

1 Star2 Stars

Tags: , ,

1 response so far!

Leave a Comment

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word