I have an input field for a phone number which allows up to 20 characters (for international numbers). I'm also using the Masked input jQuery plugin by Josh Bush to format the phone number in the input to make it 'pretty'. My problem is that in the requirements when the phone is 10 digits or less, it should use the Masked input formatting. C is the length of the country code. N is the length of the city code and the subscriber number, including any formatting, such as spaces or hyphens. E is the length of the extension number. The following table shows an example calculation of the maximum length of an international phone number (+834 91 518–400 x 123). This is a bad implementation because if the area code starts with 0105555555 or something like that then you end up getting back (01) 555-5555 instead of (010) 555-5555. The library can accurately detect the country, country calling code, and the number without the country calling code. { country: "IN", countryCallingCode: "91", nationalNumber: "9098765432 A free Phone Number Validation API helps you quickly check if a phone number is valid, as well as get additional info like city, region, country, time zone, line type, and more. I found this code in some website, and it works perfectly. It validates that the phone number is in one of these formats: (123) 456-7890 or 123-456-7890. The problem is that my client (I don't know why, maybe client stuffs) wants to add another format, the ten numbers consecutively, something like this: 1234567890. E.164 E.164 is an international standard ( ITU-T Recommendation), titled The international public telecommunication numbering plan, that defines a numbering plan for the worldwide public switched telephone network (PSTN) and some other data networks . E.164 defines a general format for international telephone numbers. To call Namibia using your mobile phone, dial the country code, the area code and the 6-digit number. Some of the common area codes in Namibia include Windhoek (61), Walvis Bay (64) and Rundu (66). Location PTv1McX.