Search code examples
phone-number

Is it possible to create a mask to handle non-north american phone numbers?


For north american phone numbers, (999) 999-9999 works pretty well for an input mask.

However, I can't find a good example that will handle non-north american numbers. I know that the number of digits can vary, so other than restricting it to digits only, is there a good example anywhere?


Solution

  • There is no generic mask, really: There are too many combinations.

    The only thing that is fixed is the international country code, usually prefixed by +.

    According to the Wikipedia Article on telephone numbering plans, most countries conform with the E.164 numbering plan.

    If I read E.164 correctly, you can safely make the following assumptions:

    • Country code: 1-3 digits

    • Network / Area code and Number: Up to 19 digits

    I would ask for the country code, and have the "area code + number" field as a 19-digit input.