The CurrencyValidator class validates the currency format. You can set the precision property in it. The Tag of CurrencyValidator is <mx:CurrencyValidator>. In this example you can see how we can use it.
|
<?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="Currency"> <currencyInfo> <amount>{txt.text}</amount> </currencyInfo> </fx:Model> <mx:CurrencyValidator source="{txt}" property="text" precision="2" trigger="{btn}" triggerEvent="click" valid="Alert.show('Validation Successful');"/> </fx:Declarations> <s:Panel title="CurrencyValidator Example" width="550"> <mx:Form height="94" width="548" backgroundColor="#101446" color="#FFFFFF"> <mx:FormItem label="Enter a amount(Rs): "> <s:TextInput id="txt" 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> |
To view this page ensure that Adobe Flash Player version 10.0.0 or greater is installed.
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.