(Preview)
Package | mx.validators |
Class | public class NumberValidator |
Inheritance | NumberValidator ![]() ![]() ![]() |
Language Version: | ActionScript 3.0 |
Product Version: | Flex 3 |
Runtime Versions: | Flash Player 9, AIR 1.1 |
![]() | Starting with Flex 4.5, Adobe recommends that you use the spark.validators.NumberValidator class as an alternative to this class. |
The NumberValidator class ensures that a String represents a valid number. It can ensure that the input falls within a given range (specified by
minValue
and maxValue
),
is an integer (specified by domain
),
is non-negative (specified by allowNegative
),
and does not exceed the specified precision
.
The validator correctly validates formatted numbers (e.g., "12,345.67")
and you can customize the thousandsSeparator
and
decimalSeparator
properties for internationalization.
MXML Syntax
The <mx:NumberValidator>
tag
inherits all of the tag attributes of its superclass,
and adds the following tag attributes:
<mx:NumberValidator allowNegative="true|false" decimalPointCountError="The decimal separator can only occur once." decimalSeparator="." domain="real|int" exceedsMaxError="The number entered is too large." integerError="The number must be an integer." invalidCharError="The input contains invalid characters." invalidFormatCharsError="One of the formatting parameters is invalid." lowerThanMinError="The amount entered is too small." maxValue="NaN" minValue="NaN" negativeError="The amount may not be negative." precision="-1" precisionError="The amount entered has too many digits beyond the decimal point." separationError="The thousands separator must be followed by three digits." thousandsSeparator="," />
More examples
Public Properties
Property | Defined By | ||
---|---|---|---|
![]() | constructor : Object
A reference to the class object or constructor function for a given object instance. | Object |
Protected Properties
Public Methods
Method | Defined By | ||
---|---|---|---|
![]() | addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Registers an event listener object with an EventDispatcher object so that the listener
receives notification of an event. | EventDispatcher | |
![]() |
Dispatches an event into the event flow. | EventDispatcher | |
![]() |
Checks whether the EventDispatcher object has any listeners registered for a specific type
of event. | EventDispatcher | |
![]() |
Indicates whether an object has a specified property defined. | Object | |
![]() |
Indicates whether an instance of the Object class is in the prototype chain of the object specified
as the parameter. | Object | |
![]() |
Indicates whether the specified property exists and is enumerable. | Object | |
![]() |
Removes a listener from the EventDispatcher object. | EventDispatcher | |
![]() |
Sets the availability of a dynamic property for loop operations. | Object | |
![]() |
Returns the string representation of this object, formatted according to locale-specific conventions. | Object | |
![]() |
Returns the string representation of the specified object. | Object | |
![]() |
Returns the primitive value of the specified object. | Object | |
![]() |
Checks whether an event listener is registered with this EventDispatcher object or any of
its ancestors for the specified event type. | EventDispatcher |
Protected Methods
Method | Defined By |
---|
Protected Constants
Property Detail
Constructor Detail
Method Detail
Examples How to use this example
NumberValidatorExample.mxml
<?xml version="1.0" encoding="utf-8"?> <!-- Simple example to demonstrate the NumberValidator. --> <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"> <fx:Script> import mx.controls.Alert; </fx:Script> <fx:Declarations> <mx:NumberValidator source="{age}" property="text" integerError="Enter Integer value" minValue="18" maxValue="50" domain="int" trigger="{myButton}" triggerEvent="click" valid="Alert.show('Validation Succeeded!');" invalid="Alert.show('Validation failed!');"/> </fx:Declarations> <s:Panel title="NumberValidator Example" width="75%" height="75%" horizontalCenter="0" verticalCenter="0"> <mx:Form left="10" right="10" top="10" bottom="10"> <mx:FormItem label="Enter an age between 18 and 50:"> <s:TextInput id="age" width="100%"/> </mx:FormItem> <mx:FormItem > <s:Button id="myButton" label="Validate" /> </mx:FormItem> </mx:Form> </s:Panel> </s:Application>
Wed Nov 21 2018, 06:34 AM -08:00