agiropoulostauros Posted April 20, 2012 Share Posted April 20, 2012 Is there a way to validate the phone number? i.e. i need it to be 10 digits exactly Thanks Link to comment Share on other sites More sharing options...
phrasespot Posted April 23, 2012 Share Posted April 23, 2012 Is there a way to validate the phone number?i.e. i need it to be 10 digits exactly If you told us your PS version that would help. Without it, I am guessing. Drop the attached file to /override/classes/ directory on your server, it is good for 1.4.7.0. But consider that most people will type brackets, hyphens, spaces etc when typing their phone numbers and maybe surprised why it is not being accepted. Better to have a few wrong phone numbers than puzzling most of your users IMO. Link to comment Share on other sites More sharing options...
andrexng Posted June 20, 2012 Share Posted June 20, 2012 Hi agiropoulostauros, I have just solved the problem of validating the phone number on the contact form. Not sure if the account registration form is same as that form that you mentioned. Nevertheless, I hope the following solution helps you and everyone else. 1) Go to AuthController.php in controllers folder. 2) Go to Line 85 and find if (!Tools::getValue('phone') AND !Tools::getValue('phone_mobile')) $this->errors[] = Tools::displayError('You must register at least one phone number'); 3) Copy and paste the following after line 85: (this is for validating the mobile phone number) $digits_mobile = strlen(Tools::getValue('phone_mobile')); if (Tools::getValue('phone_mobile') AND $digits_mobile !=10) $this->errors[] = Tools::displayError('Please enter 8 digits for the mobile phone number.'); (this is for validating the home phone number) $digits_home = strlen(Tools::getValue('phone')); if (Tools::getValue('phone') AND $digits_home !=10) $this->errors[] = Tools::displayError('Please enter 8 digits for the home phone number.'); 4) Refresh the form page, and see if it works for you. P.S Please back up the file before you can actually do the above actions. Cheers, Andre 3 Link to comment Share on other sites More sharing options...
ricky11 Posted January 31, 2013 Share Posted January 31, 2013 HI Andre, is above for version 1.5, i cant find authcontroller in 1.5? Link to comment Share on other sites More sharing options...
Ajax30 Posted February 26, 2013 Share Posted February 26, 2013 Andre, your solution works fine in Prestashop 1.5.2. Was it especially designed for it? (It does slow down my local XAMPP server though...) Thank you! Link to comment Share on other sites More sharing options...
tsuval Posted August 29, 2013 Share Posted August 29, 2013 Works good on Presta 1.4.4! Thanks! Link to comment Share on other sites More sharing options...
andrexng Posted August 30, 2013 Share Posted August 30, 2013 (edited) Sorry guys, it has been a long while since I used Prestashop and I didn't check my emails related to Prestashop. Just to answer your question, ricky11.... I think that version was 1.4... Hope you managed to solve your problem by then. Ajax30 & tsuval, it's my pleasure and I'm really glad that it works on your side. Ajax30, I think my code was designed for version 1.4... Surprised it works on 1.5.2.. All the best with your web coding works on Prestashop websites! Edited August 30, 2013 by andrexng (see edit history) Link to comment Share on other sites More sharing options...
franzneves Posted July 14, 2014 Share Posted July 14, 2014 Can I use the version 1.6.0.6? Link to comment Share on other sites More sharing options...
enisku Posted May 19, 2015 Share Posted May 19, 2015 Pleas 1.6 version?? Link to comment Share on other sites More sharing options...
Ajax30 Posted March 29, 2016 Share Posted March 29, 2016 Hi agiropoulostauros, I have just solved the problem of validating the phone number on the contact form. Not sure if the account registration form is same as that form that you mentioned. Nevertheless, I hope the following solution helps you and everyone else. 1) Go to AuthController.php in controllers folder. 2) Go to Line 85 and find if (!Tools::getValue('phone') AND !Tools::getValue('phone_mobile')) $this->errors[] = Tools::displayError('You must register at least one phone number'); 3) Copy and paste the following after line 85: (this is for validating the mobile phone number) $digits_mobile = strlen(Tools::getValue('phone_mobile')); if (Tools::getValue('phone_mobile') AND $digits_mobile !=10) $this->errors[] = Tools::displayError('Please enter 8 digits for the mobile phone number.'); (this is for validating the home phone number) $digits_home = strlen(Tools::getValue('phone')); if (Tools::getValue('phone') AND $digits_home !=10) $this->errors[] = Tools::displayError('Please enter 8 digits for the home phone number.'); 4) Refresh the form page, and see if it works for you. P.S Please back up the file before you can actually do the above actions. Cheers, Andre Where does this difference come from: "enter 8 digits" vs " $digits_mobile !=10"? Thank you! 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