RE: [PHP-DB] form field rejection

2003-02-03 Thread Hutchins, Richard
You could also look at a site like javascript.internet.com and look up a
pre-written phone number validation script and do the validation on the
client side in addition to or instead of doing it on the server side.

One reason you may want to consider doing client-side validation for
something like this is consideration for your users. Not everyone has a DSL
or Cable connection, let alone T1 or T3. If one of your users fills out your
form, hits SUBMIT, then has to wait maybe 60 seconds round trip for the
server to report that the phone number was invalid, they're probably going
to get frustrated. Any time you can get away with client side form
validation, you should use it. Especially if you're backing it up with
server-side validation. It's much more user-friendly.

Server-side validation is good to double-check to make sure the form data
has not been tampered with and is still acceptable by the server and in the
event that the user has disabled JavaScript in the browser. It's also
necessary anytime you have to validate a form entry against a database (e.g.
checking to see if a username already exists on a user account creation
form).

> -Original Message-
> From: Leif K-Brooks [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, February 02, 2003 11:53 PM
> To: Addison Ellis
> Cc: [EMAIL PROTECTED]
> Subject: Re: [PHP-DB] form field rejection
> 
> 
> 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})$/',$phonenumb
> er,$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.
> 
> 
> 
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] form field rejection

2003-02-02 Thread Leif K-Brooks
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.




--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] form field rejection

2003-02-02 Thread Addison Ellis
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
--
Addison Ellis
small independent publishing co.
114 B 29th Avenue North
Nashville, TN 37203
(615) 321-1791
[EMAIL PROTECTED]
[EMAIL PROTECTED]
subsidiaries of small independent publishing co.
[EMAIL PROTECTED]
[EMAIL PROTECTED]

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php