General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old November 25th, 2002, 06:40 AM
cutz cutz is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 8 cutz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to cutz
Exclamation phone number validation

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?

Reply With Quote
  #2  
Old November 26th, 2002, 11:56 AM
crazytrain81 crazytrain81 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 232 crazytrain81 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
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.

Reply With Quote
  #3  
Old November 26th, 2002, 03:23 PM
cutz cutz is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 8 cutz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to cutz
thx

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > phone number validation


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway