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
This is a RTFM situation!!!
instead of just $form["autopstcode"] - use str_replace("
","",$form["autopstcode"])
(e.g. strip the spaces before validating the triplets)
found in 30 seconds by typing "string" on PHP site.
-Original Message-
From: DonPro [mailto:donpro@;lclcan.com]
Sent: 15
3 matches
Mail list logo