Formatter Error : Formatter « Data Model « Flex






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.