0

Possible Duplicate:
A comprehensive regex for phone number validation

Just a simple regex required to validate telephone numbers.

Must contain only digits, and the other allowable characters are spaces and dashes.

Community
  • 1
  • 1
MAX POWER
  • 5,007
  • 15
  • 83
  • 133
  • 1
    There are many regular expression libraries on the web, did you try to google? Otherwise you could easily try to construct a regexp yourself. http://tools.ietf.org/html/rfc3966 – poke Oct 04 '10 at 17:02

2 Answers2

3

You can try:

if(preg_match('/^[\d -]+$/',$telNumber)) {
  // valid tel number.
}
codaddict
  • 429,241
  • 80
  • 483
  • 523
0

You can use this

\+?[\d -\(\)]*
Hemang
  • 1,103
  • 9
  • 19