Jump to content

Address - must contain numbers and characters


Recommended Posts

Hi,

often, the customer forgets to fill the house number in the address. 
Therefore, I need that the customer had to fill the street number. 
On the Internet I found this - if a string contains both numbers and letters.
 
$myString="abc123";
if( preg_match('([a-zA-Z].*[0-9]|[0-9].*[a-zA-Z])', $myString) )
{
echo('Has numbers and letters.');
} else {
echo("no");
}
 
I did experiments with it, but without success. I edited it in authentication.tpl and order-opc-new-account.tpl.
 
Please advise.
 
zf
Link to comment
Share on other sites

Hi,

finally I found a function "isAddress" in classes/Validate.php , which I modified as follows:

 

public static function isAddress($address)
{
// return empty($address) || preg_match('/^[^!<>?=+@{}_$%]*$/u', $address);
return empty($address) || preg_match('([a-zA-Z].*[0-9]|[0-9].*[a-zA-Z])', $address);
}
 
It seems that it works as I wanted.
zf
  • Like 1
Link to comment
Share on other sites

  • 2 years later...
×
×
  • Create New...