[re-arranging quotes to bottom posting]
In article <9556pp$sna$[EMAIL PROTECTED]>, [EMAIL PROTECTED]
("Jeff Warrington") wrote:
> > hi, im trying to fix this couple of hours but i couldnt find the
> > mistake... can somebody look at it...
> >
> > first i want to check the $co_area for 3 digital ... it must contain 3
> > digital
> >
> > if ($co_area != !ereg("([0-9]{3})",$co_area))
> > { echo " * Area code must be 3 digital"; }
> if (eregi("[^0-9]{3}",$co_area)) {
> print("area code must be digits");
> }
>
> or
>
> if (eregi("[^[:digit:]]{3}",$co_area))
>
> if you use the POSIX regex fields.
Those pass any string except where there occurs a sequence of three
non-digit chars. So "123AB", "AB", "A", "1 2 3", etc. would all slip
through as apparently valid area codes. Instead, how about:
//<-if anything but a sequence of exactly three digits from beginning to
end...
if (!eregi("^[[:digit:]]{3}$",$co_area))
{
//throw an error message
echo "Sorry, only a three digit area code is permitted!";
}
--
CC
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]