dunozf Posted October 31, 2014 Share Posted October 31, 2014 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 More sharing options...
dunozf Posted October 31, 2014 Author Share Posted October 31, 2014 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 1 Link to comment Share on other sites More sharing options...
mickeyboy1 Posted November 6, 2014 Share Posted November 6, 2014 Would this still work if the house has a name instead of a number? Link to comment Share on other sites More sharing options...
dunozf Posted November 6, 2014 Author Share Posted November 6, 2014 no, the address must contain the street (text) and number. I was inspired from http://stackoverflow.com/questions/9335915/check-if-a-string-contains-numbers-and-letters , where is the link to the php tester http://phptester.net/index.php ? lang = en zf Link to comment Share on other sites More sharing options...
mickeyboy1 Posted November 7, 2014 Share Posted November 7, 2014 (edited) Yes but what happens if the customers house just has a name and not a number? Would this throw an error? I haven't tried this, just asking Edited November 7, 2014 by mickeyboy1 (see edit history) Link to comment Share on other sites More sharing options...
dunozf Posted November 7, 2014 Author Share Posted November 7, 2014 if the customer enters only the name of the house, when saving it displays an error. zf Link to comment Share on other sites More sharing options...
Liefzebraatje Posted November 22, 2016 Share Posted November 22, 2016 this solution gifs an error on mobile devices in chrome browser. Strange, anyone else a working solution. Link to comment Share on other sites More sharing options...
Recommended Posts