Custom Field Validation

  • Posts: 8
  • Thank you received: 1
10 years 4 months ago #165071

-- HikaShop version -- : 2.3.2
-- Joomla version -- : 3.3
-- PHP version -- : 5.4.26

I've seen a few brief discussions about custom validation of custom fields... but none of them have been very helpful thus far.

I'm adept at building custom Javascript & php code and have some special validation that needs to be performed on a custom field on the checkout/registration form... I've looked and looked but can't seem to find the proper place to hack in a quick ajax call to the server to validate the field and either permit or prevent the form submitting (and displaying an error message). Suggestions?

Please Log in or Create an account to join the conversation.

  • Posts: 12953
  • Thank you received: 1778
10 years 4 months ago #165078

Hello,
Can you tell me what kind of custom field you want to use and how do you exactly want to edit it ?

Please Log in or Create an account to join the conversation.

  • Posts: 8
  • Thank you received: 1
10 years 4 months ago #165187

It's a simple text field (a number actually) into which a new user will enter a number... I need to query the database before the form is submitted to ensure that number exists in a particular table. If it does not I need to prevent Hikashop from processing the registration form and creating the new user/order until the user enters a valid number.

Please Log in or Create an account to join the conversation.

  • Posts: 82864
  • Thank you received: 13372
  • MODERATOR
10 years 4 months ago #165296

Hi,

So the field is of the table "user" or "address" I guess.
In that case, you want to edit the file "registration" (or "registration_bootstrap" if you have turned on the "use bootstrap option of the configuration) via the menu Display>Views and change the line:
echo $this->cartClass->displayButton($registerButtonName,'register',$this->params,hikashop_currentUrl(),' hikashopSubmitForm(\''.$this->form_name.'\'); return false;','id="hikashop_register_form_button"');

You'll want to put the call to hikashopSubmitForm(\''.$this->form_name.'\'); in a if statement with your ajax check so that the form is sent only if your check is valid.

Please Log in or Create an account to join the conversation.

Time to create page: 0.075 seconds
Powered by Kunena Forum