Jump to content

OPC - New customers registering can enter "blank" (hit the tab key" to bypass entering address, zip


Recommended Posts

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

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...