Re: Phone number validation
| From: | Jim Lucas [php] | Date: | Mon, 08 Apr 2002 16:39:03 +0000 |
| Subject: | Re: Phone number validation | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-92084@lists.php.net to get a copy of this message | ||
try this
preg_match("/[a-zA-Z]+/i", $str);
and if you want to go the other route.
do this
preg_match("/[^0-9\(\)\-\.\ ]+/i", $str);
this will return true if it is anything other then what is listed.
numbers 0-9
"("
")"
"-"
"."
" "
Jim Lucas
----- Original Message -----
From: "Gary" <garyb10@earthlink.net>
To: <php-general@lists.php.net>
Sent: Saturday, April 06, 2002 6:52 PM
Subject: [PHP] Phone number validation
> Hi All,
> I tried to cut a corner and use an alphabetic validation I am using
> elsewhere
> $stuff = "/^[a-zA-Z]+$/";
> if(preg_match($stuff, $value))
>
> looks like I forgot about +( )- being in phone number. What is the
> easiest way to allow these 4 characters? Are there any other characters
> that people use?
>
> TIA
> Gary
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>