Either you may remove spaces:
$form["authpstcode"]=str_replace(' ','',$form["authpstcode"])
and then compare
or change your expresion to
'(^\s*[a-z]\s*[0-9]\s*[a-z]\s*[0-9]\s*[a-z]\s*[0-9]\s*$)'
The first is better as you may put it into database column that is just
char(6)
DonPro wrote:
Hi,
This might work:
if(!eregi('(^[a-z][0-9][a-z] ?[0-9][a-z][0-9]$)',$form["authpstcode"])) {
$errors[] = 'You must input a valid Canadian postal code (A9A9A9) postal
code if he/she resides in Canada';
$continue = false;
}
Marco
--
php|architect - The magazine for PHP Profession
From: DonPro [mailto:donpro@;lclcan.com]
Sent: 15 November 2002 14:45
To: php list
Subject: [PHP] Validating postal codes
Hi,
I'm trying to validate a Canadian postal code. I've already written a
function; code as follows:
if(!eregi('(^[a-z][0-9][a-z][0-9][a-z][0-9]$)',$f
Hi,
I'm trying to validate a Canadian postal code. I've already written a
function; code as follows:
if(!eregi('(^[a-z][0-9][a-z][0-9][a-z][0-9]$)',$form["authpstcode"])) {
$errors[] = 'You must input a valid Canadian postal code (A9A9A9) postal
code if he/she resides in Canada';
$continue
4 matches
Mail list logo