1 Reply Latest reply on Oct 12, 2007 10:38 AM by widgeter

    phoneFormatter - validPatternChars Error


      I was wondering if anyone has had any issues with the <mx:PhoneFormatter> under validPatterChars?

      Here's my problem:

      When a user enters a phone number like 1234567890 the formatter works fine (###) ###-####
      ...but if a user enters 123-456-7890 then the formatter doesn't nicely format the phone number?? I have even tried the Adobe Flex example with the same results?

      Anyone have any ideas. I was think of stripping everything out first and leave just the numbers before formatting?

      Just wondering if anyone has experienced this?

      Thanks, Matt M
        • 1. phoneFormatter - validPatternChars Error
          widgeter Level 1
          In case it may help someone else....

          private function phoneFormat() : void {

          var rePhPat:RegExp = /[^0-9]+/ig; // Returns only the numbers, stripping out anything else
          var phstr:String = phoneIn.text; //anything like 123-454-7890
          var formatted_phoneIn:String = (phstr.replace(rePhPat, ""));

          // result put back into field formatted nicely
          phoneIn.text = phoneFormatter.format(formatted_phoneIn);
          ...where phoneFormatter was my
          <mx:PhoneFormatter id="phoneFormatter" ... />