AbanteCart Community
Shopping Cart Operations => Support => General Support => Topic started by: Sam_78 on May 19, 2021, 11:53:47 AM
-
Hi,
I installed V 1.13 and on create account page how can I add validation for Zip code to accept only numbers and limit 5 digits only
I can do this via Jquery in create.tpl but is there any other way to do this without editing code ? Same for phone number and other fields.
-
hi.
better way to do validation via validation hook .
public function onModelAccountCustomer_ValidateData()
{
$that = $this->baseObject;
if( !preg_match('[^0-9]', $that->request->post['postcode'] ){
$that->error['postcode'] = 'Your error text here';
}
}
-
Which file ?
Also, this will be server side validation so customer will be able to make a request using invalid zip-code. We can use this but I think there should be JAVASCRIPT validation before making this request.
Can you tell me the exact path for this hook ?
-
hmm.. i thought you created your own custom extension to affect on base functionality.
i think you should.
Also you can create account/create.post.tpl inside your extension with your js-code to extend base accoun/create.tpl
See more details here
https://abantecart.atlassian.net/wiki/spaces/DOC/pages/17694951/Extension+Process+Overview