Validate value
| From: | Jensen, Kimberlee | Date: | Sun, 11 Jul 2004 16:33:40 +0000 |
| Subject: | Validate value | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-35198@lists.php.net to get a copy of this message | ||
1. You have to allow for a space in your pattern - you can do so by hitting the space bar or using
\s. Here are some options
$pattern="/^[a-zA-Z ]+$/";
if(preg_match($pattern,$_POST['name']))
{
$pattern="/^[a-zA-Z\s]+$/";
if(preg_match($pattern,$_POST['name']))
{
$pattern="/^[a-zA-Z]+[\s]?[a-zA-Z]*$/";
if(preg_match($pattern,$_POST['name']))
{
2. Do you want other characters besides numbers in the phone, such as 333-333-3333?
Otherwise, this should do it:
$pattern="/^[\d]{10}$/";
if(preg_match($pattern,$_POST['phone']))
{