Validating custom fields and showing message to user

  • Posts: 42
  • Thank you received: 0
  • Hikashop Business
6 years 8 months ago #274327

-- HikaShop version -- : 3.1.1.
-- Joomla version -- : 3.7
-- PHP version -- : 7
-- Browser(s) name and version -- : all
-- Error-message(debug-mod must be tuned on) -- : none

Hi,
have made several custom fields and have seen it is possible to validate with for example [0-9] and this is working well. However, I have measurements in these fields and these should not be bigger than 320 (for example).
With Calc Builder I can make validations, but I do not know how to show a message to the user (front end).
I have seen in the field table that you have 'errormessage' but how do I trigger this, if at all possible from my validation in calc builder, or how do I validate a field directly in Hikashop custom Fields such that a value entered there is lower than a certain figure?
Hope you can help!
Thanks

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

  • Posts: 81361
  • Thank you received: 13036
  • MODERATOR
6 years 8 months ago #274343

Hi,

You can do that with the regex check. It's just a bit more complex:

(320|3[0-1][0-9]|[1-2][0-9][0-9]|[0-9][0-9]|[0-9])
This reads as:
- 320 or
- a text with 3 followed by 0 or 1 and then another number or
- a text with 1 or 2 followed by two numbers or
- a text with two numbers or
- a text with one number

Last edit: 6 years 8 months ago by nicolas.

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

  • Posts: 42
  • Thank you received: 0
  • Hikashop Business
6 years 8 months ago #274391

Thanks!
Your expression does not seem to work, but have found a way looking at these examples:
www.regular-expressions.info/numericranges.html
That is working very well!
Thanks again.

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

Time to create page: 0.064 seconds
Powered by Kunena Forum