Please help us to make AbanteCart Ideal Open Source Ecommerce Solution for everyone.

Support AbanteCart eCommerce

Author Topic: Zip code min length  (Read 2430 times)

Offline Sam_78

  • Sr. Member
  • ****
  • Posts: 270
  • Karma: +42/-1
    • View Profile
Zip code min length
« 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 ?

Offline dvagner

  • Core/UI Developer
  • Jr. Member
  • **
  • Posts: 73
  • Karma: +28/-1
    • View Profile
Re: Zip code min length
« Reply #1 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
     }
}

 

Powered by SMFPacks Social Login Mod