lateral Posted May 15, 2015 Share Posted May 15, 2015 Hi guys I need my new customers who register to enter a valid address via the OPC (one page Checkout) Current, all they need to do is press the Tab key to bypass the Address/Address (Line 2), zip. is there a way to force them to enter these???? Regards Greg Link to comment Share on other sites More sharing options...
NemoPS Posted May 15, 2015 Share Posted May 15, 2015 They shouldn't be allowed to save the address with that being blank, are you using a third party module? Link to comment Share on other sites More sharing options...
lateral Posted May 15, 2015 Author Share Posted May 15, 2015 Hi Nemo No, I'm using the standard OPC from Prestashop. Have a look at this screen shot. I pressed the "space" bar then "tab" and the green tick appeared: Link to comment Share on other sites More sharing options...
NemoPS Posted May 16, 2015 Share Posted May 16, 2015 Oh, but then it wont' let you through if you try saving the address, correct? The js validation on them is quite poor Link to comment Share on other sites More sharing options...
lateral Posted May 16, 2015 Author Share Posted May 16, 2015 Hi Nemo It lets you save the blank address, Address (Line 2) and City.... Is there any way to stop this from happening? Regards Greg Link to comment Share on other sites More sharing options...
NemoPS Posted May 18, 2015 Share Posted May 18, 2015 True, odd, it does for me as well. This seems to work: modify classes/Validate.php, isAddress method, to this public static function isAddress($address) { return (bool)trim($address) && preg_match(Tools::cleanNonUnicodeSupport('/^[^!<>?=+@{}_$%]*$/u'), $address); } Link to comment Share on other sites More sharing options...
lateral Posted May 18, 2015 Author Share Posted May 18, 2015 Thanks Nemo I'll try this and report back. Regards Greg Link to comment Share on other sites More sharing options...
lateral Posted May 18, 2015 Author Share Posted May 18, 2015 Hi Nemo, This almost works. It should be only forcing the mandatory fields (address*, City* etc) and not the optional fields such as address (line 2).... Regards Greg Link to comment Share on other sites More sharing options...
NemoPS Posted May 20, 2015 Share Posted May 20, 2015 That might be a problem, as they both use isAddress as validation field. Try cloning that method, name it isAddressOrNothing and use that in the Address class definition on the validate part:'address2' => array('type' => self::TYPE_STRING, 'validate' => 'isAddress', 'size' => 128), Link to comment Share on other sites More sharing options...
lateral Posted May 25, 2015 Author Share Posted May 25, 2015 Thanks Nemo. I'll try this and let you know how I go. Regards Greg Link to comment Share on other sites More sharing options...
lateral Posted May 25, 2015 Author Share Posted May 25, 2015 Hi Nemo I have been playing around with this trying to get it to work but can't. I'm sure that I have not cloned and modified the code for the Address Line 2 correctly. Here is the amended code from the validate.php: /** * Check for a postal address validity Address Line 1 * * @param string $address Address to validate * @return boolean Validity is ok or not */ public static function isAddress($address) { /* return empty($address) || preg_match('/^[^!<>?=+@{}_$%]*$/u', $address); */ return (bool)trim($address) && preg_match(Tools::cleanNonUnicodeSupport('/^[^!<>?=+@{}_$%]*$/u'), $address); } /** * Check for a postal address validity Address Line 2 * * @param string $address Address to validate * @return boolean Validity is ok or not */ public static function isAddressOrNothing($address) { /* return empty($address) || preg_match('/^[^!<>?=+@{}_$%]*$/u', $address); */ 'address2' => array('type' => self::TYPE_STRING, 'validate' => 'isAddress', 'size' => 128), And this is what I have in my order-opc-new-account.tpl file: <div class="required text form-group"> <label for="address1">{l s='Address'} <sup>*</sup></label> <input type="text" style="text-transform:capitalize;" class="text form-control validate" name="address1" id="address1" data-validate="isAddress" value="{if isset($guestInformations) && isset($guestInformations.address1) && isset($guestInformations) && isset($guestInformations.address1) && $guestInformations.address1}{$guestInformations.address1}{/if}" /> </div> {elseif $field_name eq "address2"} <div class="text is_customer_param form-group"> <label for="address2">{l s='Address (Line 2)'}</label> <input type="text" style="text-transform:capitalize;" class="text form-control validate" name="address2" id="address2" data-validate="isAddress" value="{if isset($guestInformations) && isset($guestInformations.address2) && isset($guestInformations) && isset($guestInformations.address2) && $guestInformations.address2}{$guestInformations.address2}{/if}" /> </div> I really appreciate your help with this Nemo. Could you also include in the validation for Address1 that the length can't be less that "2"? This should stop people putting in a "-"... Thanks again. Regards Greg 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