Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Flex
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Flex
Flex-TextInput
Booma Devi
Ranch Hand
Posts: 61
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi,
Can you please help how to validate the currency in the textinput...
For example when the user type the amount as 2T then amount should be converted to 2,000.00.
Booma Devi
Ranch Hand
Posts: 61
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Below is the code:
<?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" xmlns:curr="*"> <curr:CurrencyTextInput/> </s:Application> CurrencyTextInput.as package { import flash.events.KeyboardEvent; import mx.controls.TextInput; import mx.formatters.NumberFormatter; public class CurrencyTextInput extends TextInput { override protected function keyUpHandler(event:KeyboardEvent):void { super.keyUpHandler(event); if( text.length == 0 ) { return; } var numberString:String= text; if(numberString.charAt(numberString.length -1) == "k" ) { numberString=numberString.substr( 0, numberString.length - 1 ); var number:Number=Number(numberString); if(number>=1 || number<=1) { super.text=(number*1000).toString(); var result:String=super.text; valResult(result); validateNow(); textField.setSelection(super.text.length,super.text.length); } } } public function valResult(result:String):void { var formatter:NumberFormatter = new NumberFormatter(); formatter.precision = 2; super.text=formatter.format(result); } } }
Consider Paul's
rocket mass heater
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Displaying line # with JTextArea
Determining whether object at current caret position is plain text or a component
Multiple files?
how to use textbox as dropdown or is there any controlin jsf
DTD and validation - RSS 0.91
More...