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

Support AbanteCart eCommerce

Author Topic: Validation  (Read 343 times)

Offline Sam_78

  • Full Member
  • ***
  • Posts: 227
  • Karma: +41/-1
    • View Profile
Validation
« 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.

Offline abolabo

  • core-developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 1961
  • Karma: +300/-12
  • web for all, all for web!
    • View Profile
    • AbanteCart
Re: Validation
« Reply #1 on: May 20, 2021, 03:55:05 AM »
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';
     }
}
“No one is useless in this world who lightens the burdens of another.”
― Charles Dickens

Offline Sam_78

  • Full Member
  • ***
  • Posts: 227
  • Karma: +41/-1
    • View Profile
Re: Validation
« Reply #2 on: May 20, 2021, 01:56:00 PM »
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 ?

Offline abolabo

  • core-developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 1961
  • Karma: +300/-12
  • web for all, all for web!
    • View Profile
    • AbanteCart
Re: Validation
« Reply #3 on: May 20, 2021, 05:34:06 PM »
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
“No one is useless in this world who lightens the burdens of another.”
― Charles Dickens

 

Powered by SMFPacks Social Login Mod