Formatter Error : Formatter « Data Model « Flex

Home
Flex
1.Chart
2.Components
3.Container
4.Data Model
5.Development
6.Effects
7.Event
8.Graphics
9.Grid
10.Style
Flex » Data Model » FormatterScreenshots 
Formatter Error
Formatter Error
    
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
  <mx:Script>
    
    [Bindable]
    public var results:String="";
    public function formatNow():void {
      phoneFormatter.format(phone.text);
      if(phoneFormatter.error == "Invalid value"){
         results=phoneFormatter.error+" - "+ phone.text;
      else {
        results=phoneFormatter.format(phone.text);
        phone.text=phoneFormatter.format(phone.text);
      }
    }
  
  </mx:Script>

  <mx:PhoneFormatter id="phoneFormatter" formatString="(###) ###-####" validPatternChars="#-() "/>

  <mx:Panel title="Formatter Error Example" width="300" height="300">
      <mx:HBox>
        <mx:Label text="Phone number:" />
        <mx:TextInput id="phone" width="75%" change="formatNow()" restrict="0-9()-."/>
        <mx:TextArea id="formatterResults" htmlText="{results}" width="100%" height="100%" editable="false"/>
      </mx:HBox>
  </mx:Panel>
</mx:Application>

   
    
    
    
  
Related examples in the same category
1.Data Formatting Using MXML FormattersData Formatting Using MXML Formatters
2.Formatting data with the formatter classesFormatting data with the formatter classes
3.Edit Event FormatterEdit Event Formatter
4.End Edit Event FormatterEnd Edit Event Formatter
5.Set up the formatters.
w_w__w._j_av__a___2_s.__c_o_m___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.