Custom field of format type date is not validated

  • Posts: 78
  • Thank you received: 4
  • Hikamarket Multivendor Hikashop Business
12 years 4 months ago #57248

Hi, I have hikashop business edition (latest version).
I have a custom field of format date.
The format in hikashop is defined as %d.%m.%y
However, this is not validated. The user can enter any date, also not existing ones, e.g. 55.20.2012

Please advise how to make the validation working.

Thanks and br

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

  • Posts: 82818
  • Thank you received: 13361
  • MODERATOR
12 years 4 months ago #57295

Hi,

There is no validation of the date. That format option only allows you to have that format when the date is displayed in the field from the day the user clicked in the dynamic calendar of the custom field.
Adding a validation system would be extremely difficult and there are lots of possibilities.

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

  • Posts: 78
  • Thank you received: 4
  • Hikamarket Multivendor Hikashop Business
12 years 4 months ago #57311

Hi,
Thanks for the answer.
I do not understand, why the date is not validate.
According to this post, there is a function check_date that verifies the entered date:

www.hikashop.com/en/forum/4-how-to/33707...tom-field.html#33707

Quote:
It will be in all versions of course.
It will be released with next version in several weeks.

If you want it now, you can just add the code:
if(!selectedDate){
selObj.value=\'\';
alert(\''.JText::_('INCORRECT_DATE_FORMAT',true).'\');
return false;
}

after the line:
var selectedDate = new Date(selObj.value);

in that same file and it will display an error message when the date doesn't have the correct format.
Also, the line below will have to be added to your translation file:
INCORRECT_DATE_FORMAT="Incorrect date format"

Could you please clarify ?

Thanks and br

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

  • Posts: 82818
  • Thank you received: 13361
  • MODERATOR
12 years 4 months ago #57385

That code is only activated when the date future/past option is set because in order to do the check on the past/future date, it has to compare the date selected with the current date and so it needs to match the format of the field.
So it's not activated otherwise.

Actually, looking at the code, I think that I found a way to do it by reusing the code from that functionality.
Could you try to replace the file administrator/components/com_hikashop/classes/field.php with this one and see if that works ?

Attachments:

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

  • Posts: 29
  • Thank you received: 0
12 years 3 weeks ago #71665

Hi Nick.
There's any way to change the date to display the month in letters instead of numbers in a custom field

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

  • Posts: 82818
  • Thank you received: 13361
  • MODERATOR
12 years 3 weeks ago #71988

Yes. You can change the format with the "format" option of your custom field.
By default you have: %Y-%m-%d
It should do what you want with: %Y-%M-%d

All the format parameters are listed here:
php.net/manual/en/function.date.php

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

Time to create page: 0.072 seconds
Powered by Kunena Forum