Search code examples
c#asp.netasp.net-corevalidationphone-number

Validate a phone number?


What are the conditions to validate a phone number?

Well firstly it has to be a numerical value, which can include the following numbers 0123456789 and the plus symbol +.

But what about the following conditions, where do you get this data?

-It has to be in the format [country dial code + area code + phone number]

-It has to be a min and max length

EDIT: also what is the min and max length of a mobile/cell phone number?


Solution

  • It's probably not worth trying to validate a phone number if the phone can be anywhere in the world.

    1. What about extensions?
    2. 1-800-Flowers
    3. Numbers are different depending on where the call originates (inside/outside the country)

    The places that I've seen that actually need to verify it (like craigslist) call the number and make you verify the information they give you over the phone.