Datepicker - Allow to pick only some days of a week

gvouliakis 16 Jun, 2012
Dear Bob,

Is it possible to allow user to pick only specific days of a week
using datepicker?

For example I have:
Excursion 1 - Operates only Mon & Fri
Excursion 2 - Operates only Tue, Sat & Sun

So is it possible in datepicker to disable some days of a week and leave
"pickable" only specific ones?

For now I have a simple form for the client
http://tigakiexpress.gr/en/excursions/land/book-land-excursion

Thanks,
George
GreyHead 18 Jun, 2012
Hi George,

There isn't a way of directly blocking days of the week in either of the DatePickers :-(

There is an option to set availableDates (or alternatively nonAvailable Dates). You could use this in combination with minDate and MaxDate (to set a range) but you'd need to add code to calculate the string of dated to be made available.

Here's the section from the MooTools DatePicker docs:

minDate: (Date instance, string, defaults to null) Minimum date allowed to pick. Blocks anything before.

maxDate: (Date instance, string, defaults to null) Maximum date allowed to pick. Blocks anything after.

availableDates: (object, defaults to null) When only a few dates should be selectable. An object like {2011: {1: [19, 29, 31], 3: [5, 19, 24]}} with all the dates (year -> months -> days).

invertAvailable: (boolean, defaults to false) Invert the availableDates option.


Bob
gvouliakis 18 Jun, 2012
Thanks Bob!

I was searching Mootools DatePicker docs but availableDates object didn't got my attention. I will try to implement this. For now I decided to solve this issue using AJAX to read the database in order to update HTML select tags with proper options.

Thanks a lot!

George
gvouliakis 24 Jun, 2012
Dear Bod,

Check out the "excursions" form using the powerfull AJAX feature of ChronoForms
as a solution for allowing users picking up only correct dates for each excursion:

http://tigakiexpress.gr/en/excursions/sea/book-sea-excursion

Now I will start tests using JSON and availableDates object of Mootools DatePicker.

Regards,
George
GreyHead 24 Jun, 2012
Hi George,

That works very nicely - well done!!

Bob
GreyHead 26 Aug, 2012
Hi,

Just a little update. I have a version of the MooTools Datepicker which includes code to allow you to select days of the week.

After a steep learning curve I have posted this on GitHub where - hopefully - it will be included in a future version of the DatePicker; meanwhile if you need this you can get the modified file from my GitHub page

Bob
This topic is locked and no more replies can be posted.