1

This is my js code for my datepicker:

 Calendar.setup({
 inputField : 'scheduled_ajax_update',
 ifFormat : '%d-%m-%Y',
 button : 'scheduled_ajax_update_trig',
 align : 'Bl',
 singleClick : true,
 disableFunc: function(date) {
 var now = new Date();
 if(date.getFullYear() < now.getFullYear()) { return true; }
 if(date.getFullYear() == now.getFullYear() && date.getMonth() < now.getMonth()) { return true; }
 if(date.getMonth() == now.getMonth() && date.getDate() < now.getDate()) { return true; }
 }
 });

It disables of the past days. My weird issue is that I cannot select any values from the current month, if my selected day is in the past. See img:

enter image description here

In this case I cannot select 27 or 28 .

If I click on the next month and then I go back to my current month I can choose 27 or 28.

No error messages in the console. Do you know why is this happening :) ?

Thank you!

Aasim Goriya
5,4622 gold badges30 silver badges54 bronze badges
asked Feb 27, 2018 at 8:05

1 Answer 1

0

According to this post the currentDateEl is set null , so I adapted my disableFunc script, like:

 disableFunc: function(date) {
 var now = new Date();
 this.currentDateEl = now.getDate();
 if(date.getFullYear() < now.getFullYear()) { return true; }
 if(date.getFullYear() == now.getFullYear() && date.getMonth() < now.getMonth()) { return true; }
 if(date.getMonth() == now.getMonth() && date.getDate() < now.getDate()) { return true; }
 }

Now I am able to select the days from my current month if my current day is in the past.

answered Feb 27, 2018 at 8:33

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.