|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
hi
help me on this... $pn is phone number the format is country+space+city+space+phonenumber+(ext)+ number example 1 800 4545456454 (w|w/0) ext 45454 Is my code correct? if (!eregi("^[0-9]+[[:space:]]+[0-9]+[[:space:]]+[0-9]+([[:space:]].ext[[:space:]]+[0-9]+)$",$pn)) return 0; else return 1; --> 45645645646 == correct --> 1 800 4545454545 == incorrect... It didnt work well Can anyone tell me whats wrong? |
|
#2
|
|||
|
|||
|
try these:
preg_match("/\d{3}\w?\d{3}\w?\d{4}\w?(\wext\w\d+/i", $pn) ? return true : return false; this will check for : xxx xxx xxxx [ext xxx..] , ext optional if you want to allow xxx-xxx-xxxx, use this one: preg_match("/\d{3}(\w|-)?\d{3}(\w|-)?\d{4}\(w|-)?(\wext\w\d+/i", $pn) ? return true : return false; Last edited by crazytrain81 : November 26th, 2002 at 12:50 PM. |
|
#3
|
|||
|
|||
|
thx
![]() |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > phone number validation |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|