Using libPhoneNumber for phone number formatting
intlTelInputUtils.formatNumber('01751234567', 'DE', intlTelInputUtils.numberFormat.INTERNATIONAL)
Next we can use getNumberType to learn the types of a number:
This returns 1, which means mobile. If you try a landline number like "02632123456", you get back 0. In the table below we list the types for you.
|2||Fixed or Mobile||In some regions (e.g. the USA), it is impossible to distinguish between fixed-line and mobile numbers by looking at the phone number itself.|
|5||Shared Cost||The cost of this call is shared between the caller and the recipient, and is hence typically less than premium rate calls.|
|6||VOIP||Voice over IP numbers. This includes TSoIP (Telephony Service over IP).|
|7||Personal Number||A personal number is associated with a particular person, and may be routed to either a mobile or fixed line number.|
|9||UAN||Used for 'Universal Access Numbers' or 'Company Numbers'. They may be further routed to specific offices, but allow one number to be used for a company.|
|10||VoiceMail||Used for 'Voice Mail Access Numbers'.|
|-1||Unknown||A phone number is of type unknown when it does not fit any of the known patterns for a specific region.|
The function intlTelInputUtils.getExampleNumber can query you an example number to show in the user interface. The function takes the country code, whether to get national format and the number type you need. Let's query various types for the USA:
intlTelInputUtils.getExampleNumber('US', 0, 0) + " " +
intlTelInputUtils.getExampleNumber('US', 1, 0) + "\r" + intlTelInputUtils.getExampleNumber('US', 0, 3) + " " + intlTelInputUtils.getExampleNumber('US', 1, 3) + "\r" + intlTelInputUtils.getExampleNumber('US', 0, 4) + " " + intlTelInputUtils.getExampleNumber('US', 1, 4) + "\r" + intlTelInputUtils.getExampleNumber('US', 0, 8) + " " + intlTelInputUtils.getExampleNumber('US', 1, 8)
+1 201-555-0123 (201) 555-0123+1 800-234-5678 (800) 234-5678+1 900-234-5678 (900) 234-5678
Next you may want to check intlTelInputUtils.isValidNumber to check if a number is valid and returns a boolean. For more details use intlTelInputUtils.getValidationError function to do the same, but get back the result as an integer. Value 0 means possible, 1 an invalid country code, 2 a too short number, 3 a too long number and 4 in case the given text is not a number.
The example for FileMaker and Xojo will be included with next pre-release of our plugins. Please don't hesitate to contact us with questions or to get an early copy.