c64girl Posted August 10, 2023 Share Posted August 10, 2023 How to make 9 digits validation no more nor less but 9 numbers only? I Found this: /js/validate.js function validate_isPhoneNumber(s) { var reg = /^[+0-9. ()-]+$/; return reg.test(s); } /classes/Validate.php public static function isPhoneNumber($number) { return preg_match('/^[+0-9. ()\/-]*$/', $number); } Link to comment Share on other sites More sharing options...
endriu107 Posted August 10, 2023 Share Posted August 10, 2023 if (strlen($number) == 9){ return preg_match('/^[+0-9. ()-]*$/', $number); } else { return false; } Link to comment Share on other sites More sharing options...
c64girl Posted August 11, 2023 Author Share Posted August 11, 2023 13 hours ago, endriu107 said: if (strlen($number) == 9){ return preg_match('/^[+0-9. ()-]*$/', $number); } else { return false; } Not working Link to comment Share on other sites More sharing options...
AddWeb Solution Posted August 14, 2023 Share Posted August 14, 2023 On 8/10/2023 at 6:54 PM, c64girl said: How to make 9 digits validation no more nor less but 9 numbers only? Hi, Try this: In /js/validate.js file, function validate_isPhoneNumber(s) { var reg = /^[0-9]{9}$/; return reg.test(s); } In /classes/Validate.php public static function isPhoneNumber($number) { return preg_match('/^[0-9]{9}$/', $number); } Once you made the above changes, Clear the cache and check If it works! Thanks! Link to comment Share on other sites More sharing options...
c64girl Posted August 16, 2023 Author Share Posted August 16, 2023 (edited) On 8/14/2023 at 8:26 AM, AddWeb Solution said: Hi, Try this: In /js/validate.js file, function validate_isPhoneNumber(s) { var reg = /^[0-9]{9}$/; return reg.test(s); } In /classes/Validate.php public static function isPhoneNumber($number) { return preg_match('/^[0-9]{9}$/', $number); } Once you made the above changes, Clear the cache and check If it works! Thanks! Thank You for idea but it still not working after making changes and clear cache. Edited August 16, 2023 by c64girl (see edit history) Link to comment Share on other sites More sharing options...
c64girl Posted August 16, 2023 Author Share Posted August 16, 2023 On 8/14/2023 at 8:26 AM, AddWeb Solution said: Hi, Try this: In /js/validate.js file, function validate_isPhoneNumber(s) { var reg = /^[0-9]{9}$/; return reg.test(s); } In /classes/Validate.php public static function isPhoneNumber($number) { return preg_match('/^[0-9]{9}$/', $number); } Once you made the above changes, Clear the cache and check If it works! Thanks! I know what is the problem. If someone have allready put it a number with + or - or space or more or less than 9 digits it brake the PS for him in checkout. Link to comment Share on other sites More sharing options...
c64girl Posted August 23, 2023 Author Share Posted August 23, 2023 I fixed the error cleaning all + - ( ) spaces etc from database table ps_address in column phone Link to comment Share on other sites More sharing options...
AddWeb Solution Posted August 23, 2023 Share Posted August 23, 2023 49 minutes ago, c64girl said: I fixed the error cleaning all + - ( ) spaces etc from database table ps_address in column phone Great! Thanks for the update. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now