Possible Duplicate:
US Phone Number Verification
I need to validate US phone number. It could be in the format:
xxx-xxx-xxxx
(xxx) xxx xxxx
(xxx)-xxx-xxxx
xxxxxxxxxx
but it should not be
xxx-xxx-xxxx-
-xxx-xxx-xxxx
It should accept digits, hyphens, space and parentheses.
Currently I use
^\[0-9 \-\. ]+$
which does not validate dash at the beginning or end.
^\(?\d{3}\)?[- ]?\d{3}[- ]?\d{4}$
Well my idea is (after some searching) not new at all! Look at this:
A comprehensive regex for phone number validation
This is an Excellent suggestion btw.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With