Re: form field rejection

From: Date: Mon, 03 Feb 2003 04:52:33 +0000
Subject: Re: form field rejection
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-25362@lists.php.net to get a copy of this message
Try something like this (untested): $phonenumber = '(123)-123-1234'; $phonenumber = preg_replace('/[^0-9]/','',$phonenumber); if(!preg_match('/^([0-9]{3})([0-9]{3})([0-9]{4})$/',$phonenumber,$matches){ die('Invalid phone number.'); } $full_number = $matches[0]; $areacode = $matches[1]; $exchange = $matches[2]; $number = $matches[3] $banned_exchanges = array('321','654'); if(in_array($exchange,$banned_exchanges)){ die('Bad exchange.'); } Addison Ellis wrote:
hello,
    thank you for your time...
    what is the best way for me to have a form field, "phone" reject certain phone prefixes?
for example: someone enters 321-1791 and "321" prefix can not be allowed as an entry...
    thank you again, addison
-- The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law.

« previous php.db (#25362) next »