I am writing a php application that asks people for their phone number in Lebanon. I don’t want to be very strict in the input format, so I run into some validation problems.
Lebanese phone number looks like this.
961 3 123456
961 : country code. I want it to be valid with or without it.
3 : area code. here where difficult. possible code codes are 03, 70 and 71. When a country code is present, 03 drops to 0 and becomes 3, and 70 and 71 are equal with or without a country code.
123456 : phone number, always 6 digits.
Here are the formats I'm trying to check:
961 3 123456
961 70 123456
961 71 123456
03 123456
70 123456
71 123456
spaces here are just for clarity, I check after removing all spaces and non-alphanumeric characters.
which would be great if someone can help. thank
source
share