I need to write validation to check if a phone number is a valid USA cell / mobile phone number. I have found examples for landlines but not cell / mobile phones. Can anyone point me in the right direction with this?
Asked
Active
Viewed 476 times
-1
-
US mobile numbers have the same format as landline numbers. – Paul Jan 29 '19 at 09:09
-
Hi Paul, I read they were but I am looking for a way to distinguish between landline and cellphones to be able to send an SMS to just cell phones. – Lint Jan 29 '19 at 09:45
-
That's virtually impossible using just regex now. In the early days you could distinguish mobile numbers looking at the second triplet of numbers but due to high request for new numbers, this is not a solid way anymore. You need to use reverse lookup services to truly do that. – Paul Jan 30 '19 at 10:07
1 Answers
1
you can use Google's phone number handling library. Maybe better than regex. Here: https://github.com/giggsey/libphonenumber-for-php

Kristijan Mikulec
- 164
- 1
- 13
-
Thank you for the recommendation Kristijan, the number handling library works a treat! – Lint Jan 30 '19 at 16:17
-