The PhoneFormatter class changes a number into a phone number format.
The PhoneFormatter class changes a number into a phone number format.The PhoneFormatter class changes a number into a phone
number format.
You can use the formatString property for formatted a number. The default
area code is (###). You can set the areaCodeFormat property for area code.
If an error occurs this error is saved to the error property. The error property
has two types of error values: Invalid value, Invalid format. The tag of
NumberFormatter is <mx:NumberFormatter>. You will be declare a formatter in <fx:Declarations>
tag.
|
<?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"><![CDATA[ import mx.events.ValidationResultEvent;{ result = pnValidator.validate(); if (result.type==ValidationResultEvent.VALID) {phonelbl.text= phoneFormatter.format(phonetxt.text); } else {phonelbl.text= "Invalid Phone No.";} } ]]> validPatternChars="#-() "/> <mx:PhoneNumberValidator id="pnValidator" source="{phonetxt}" property="text"/> </fx:Declarations></s:Application> |
To view this page ensure that Adobe Flash Player version 10.0.0 or greater is installed.