next2u next2u - 3 years ago 132
PHP Question

Magento date picker is not working when current date is disable

I am using the

magento date picker
in front end for select Delivery date of product. I want to disable the previous dates, today and tomorrow. For this I use:

disableFunc: function(date) {
var now = new Date(Date.now() + 48 * 60 * 60 * 1000);
if(date.getFullYear() < now.getFullYear()) { return true; }
if(date.getFullYear() == now.getFullYear()) { if(date.getMonth() < now.getMonth()) { return true; } }
if(date.getMonth() == now.getMonth()) { if(date.getDate() < now.getDate()) { return true; } }
},


The
dates are disabled
..OK. But
I can't select the enabled dates from date picker.


If I use

var now = new Date();


instead of

var now = new Date(Date.now() + 48 * 60 * 60 * 1000);


The previous days only will disable. But the enabled dates can select from date picker.

Please help me..

Answer Source

Finally I got the solution. In js/calendar/calendar.js there is a variable currentDateEl. By default it is null.You just need to set this.currentDateEl to current date.

var currentDate = new Date();
var day = currentDate.getDate();
var month = currentDate.getMonth() + 1;
var year = currentDate.getFullYear();
var dmy =  day + "/" + month + "/" + year;
this.currentDateEl = dmy;

and issue is solved now.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download