Home Tutorial Flex Flex4 Components NumberValidator in Flex4

 
 

NumberValidator in Flex4
Posted on: May 28, 2010 at 12:00 AM
The NumberValidator class validates a number. You can specify the minimum and maximum range of value by using the minValue and maxValue property.

NumberValidator in Flex4:

The NumberValidator class validates a  number. You can specify the minimum and maximum range of value by using the minValue and maxValue property. You can specify the domain property for integer value. You can check the value is negative or not by using allowNegative property.
The tag of NumberValidator is <mx:NumberValidator>.

Example:

<?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">

<fx:Script>

<![CDATA[

import mx.controls.Alert;

]]>

</fx:Script>

<fx:Declarations>

<fx:Model id="CheckNumber">

<numberInfo>

<Number>{agetxt.text}</Number>

</numberInfo>

</fx:Model>

<mx:NumberValidator source="{agetxt}" property="text"

integerError="Enter Integer value"

minValue="21" maxValue="35" domain="int"

trigger="{btn}" triggerEvent="click"

valid="Alert.show('Validation Successful');"/>

</fx:Declarations>

<s:Panel title="NumberValidator Example" width="550">

<mx:Form height="94" width="548" backgroundColor="#101446" color="#FFFFFF">

<mx:FormItem label="Enter an age between 21 and 35: ">

<s:TextInput id="agetxt" width="100%" color="#000000"/>

</mx:FormItem>

<mx:FormItem >

<s:Button id="btn" label="Check Validation" chromeColor="#5F1B0C"/>

</mx:FormItem>

</mx:Form>

</s:Panel>

</s:Application>

Output:

Running Application:

To view this page ensure that Adobe Flash Player version 10.0.0 or greater is installed.

Download this code

Related Tags for NumberValidator in Flex4:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.