AbanteCart Community

Shopping Cart Operations => Support => General Support => Topic started by: Sam_78 on January 03, 2020, 11:07:27 AM

Title: Zip code min length
Post by: Sam_78 on January 03, 2020, 11:07:27 AM
Hi is there any setting where I can set that zip code should be 5 characters only
I am doing it using $('#AccountFrm_postcode').attr('maxlength', '5'); but a customer entered 4 digit instead of 5 and registration went through
So is there any validation setting or a better way to do this ? or should I handle it through JQuery only ?
Title: Re: Zip code min length
Post by: dvagner on January 27, 2020, 01:22:32 AM
You can create extension with Hook method like this:

public function onModelAccountCustomer_ValidateData()
{
$that = $this->baseObject;
 if ($this->baseObject_method !== 'validateRegistrationData') {
            return;
  }
if (!$that->request->is_POST()) {
return;
}
if ((mb_strlen($that->request->post['postcode']) !=5)) {
            $that->error['postcode'] = $that->language->get('error_postcode');   //Your custom error message here
     }
}