Buy Now
Sign in

Chronoforms 6 - Time limits

gberlisk , December 21 2017
G
gberlisk
How to set time range in time/date picker?
For example: user can pick only times between 8am anf 7pm.

Kind regards

Gregor
admin
Hi Gregor,

You can set the start/end dates, but I did not try to set the time before, did you try to include the time in those fields ?

Best regards
Max
If your main question got answered then please mark the answer using the button!​
​Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
G
gberlisk
Hi Max,​
​​
​I've tried but it didn't work and it can't work. I've checked the code and found this:​
​​
$.G2.boot.calendar = function(Container){​
​//calendar​
​Container.find('[data-calendar]').each(function(i, calfield){​
​var mindate = null;​
​if($(calfield).data('mindate')){​
​var parts = $(calfield).data('mindate').split('-');​
​var mindate = new Date(parts[0], parts[1]-1, parts[2]); ​
​}​
​var maxdate = null;​
​if($(calfield).data('maxdate')){​
​var parts = $(calfield).data('maxdate').split('-');​
​var maxdate = new Date(parts[0], parts[1]-1, parts[2]); ​
​}

​​
​First, the problem is delimiter "-" wihich is only used for date.​
​Second, new Date() is having only 3 parameters (for date).​
​​
​So, if anyone need to work this, has to change te code. My code probably is not optimal but it works for my needs. I'm not using seconds in time.​
​This is my code:​
​​
$.G2.boot.calendar = function(Container){​
​//calendar​
​Container.find('[data-calendar]').each(function(i, calfield){​
​var mindate = null;​
​if($(calfield).data('mindate') && $(calfield).data('type') == 'time'){​
​var parts = $(calfield).data('mindate').split(':');​
​var mindate = new Date(0, 0, 0, parts[0], parts[1], 0); ​
​} else if($(calfield).data('mindate')){​
​var parts = $(calfield).data('mindate').split('-');​
​var mindate = new Date(parts[0], parts[1]-1, parts[2]); ​
​}​
​var maxdate = null;​
​if($(calfield).data('maxdate') && $(calfield).data('type') == 'time'){​
​var parts = $(calfield).data('maxdate').split(':');​
​var maxdate = new Date(0, 0, 0, parts[0], parts[1], 0); ​
​} else if($(calfield).data('maxdate')){​
​var parts = $(calfield).data('maxdate').split('-');​
​var maxdate = new Date(parts[0], parts[1]-1, parts[2]); ​
​}

​​
​File location in my case is: {joomla root site}/libraries/cegcore2/cache/69c397d7a296016b971beced5e01ca84.js​
​​
​Kind regards​
​​
​Gregor
Attachments
timelimit1.png
timelimit1.png
(11.96 KiB)
107 Downloads/Views
timelimit2.png
timelimit2.png
(5.66 KiB)
97 Downloads/Views
admin
Hi Gregor,
Thank you!
This feature is now available in the core, you can set the open hours in the calendar field advanced settings.
Best regards
Max
If your main question got answered then please mark the answer using the button!​
​Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!