2 Replies Latest reply on Feb 16, 2014 5:43 PM by berocca

    Allow Multiple Phone Number Formats

    berocca Level 1

      Hi folks,

       

      In the past I have always set the Phone Number format using the simple Arbitrary Mask feature in the text box properties e.g. (99) 9999 9999 but I have a form where two different phone number formats are acceptable (an Australian landline OR mobile).

       

      They are:

       

      (99) 9999 9999

      9999 999 9999

       

      Is this only possible through the magic of Javascript? I have tried Googling and found nothing.

        • 1. Re: Allow Multiple Phone Number Formats
          gkaiseril MVP & Adobe Community Professional

          Yes, but you will have to use the RegExp object to specify the format images. You may have to use several logical comparisons to cover all possible phone numbers.

           

          Is Australian Phone Number

          • 2. Re: Allow Multiple Phone Number Formats
            berocca Level 1

            Thank you for your reply GKaiseril. I think I'm starting to undertsand it a little bit, especialyul after reading a similar thread that you contruibuted to here: http://forums.adobe.com/thread/861867

             

            My understanding is that the "vr re_NA_Phone_Commit =" bit specifies where the spaces are in the strong of numebrs, where the brackets go etc. But doesn't this still only set one type of format?

             

             

            If I use the following code, it turns 0399999999 (an example landline number) into (03) 5499 9999, great! But if I typed in 0499999999 (an example mobile number) I want it to become 0499 999 999 becasue that's how we format mobile numbers.

             

            // custom format

            var re_NA_Phone_Commit = /^\(?([0-9]{2})\)?[. ]?([0-9]{4})[-. ]?([0-9]{4})$/

            if(re_NA_Phone_Commit.test(event.value)) 

            event.value = "("+ RegExp.$1 +") " + RegExp.$2 + "-" + RegExp.$3;

            else {

            event.value = "";

            event.rc = false;

            }

            // end custom format