News:

AbanteCart v1.4.2 is released.

Main Menu

Do you like AbanteCart? Please rate AbanteCart or share your experience with other eCommerce entrepreneurs. Go to Softaculous rating page to add your rating or write a review

Zip code min length

Started by Sam_78, January 03, 2020, 11:07:27 AM

Previous topic - Next topic

Sam_78

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 ?

dvagner

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
     }
}

Forum Rules Code of conduct
AbanteCart.com 2010 -