• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 331
  • Last Modified:

Disable all days except monday on js calendar

Hello!

I need to have all days disabled except monday on my calendar. Any idea how to do this?

Here's my code at the moment....



$(function() {
$('#os0').datepicker({dateFormat: 'dd/mm/yy', minDate: 1, beforeShowDay: nonWorkingDates});
                                                
     setMinDate(); // Set it now
      setInterval(setMinDate, 60000); // And check every minute
});

//Now





function nonWorkingDates(date) {
    if( date.getTime() == new Date(2013,1,10,0,0,0).getTime() )  return [true, ''];
      
      var closedDates = [[1, 04, 2013], [06, 05, 2013], [27, 05, 2013], [26, 08, 2013], [25, 12, 2013], [26, 12, 2013],[14, 02, 2013]],
           day = date.getDay();
           for (var i = 0; i < closedDates.length; i++) {
            if (date.getDate() == closedDates[i][0] && date.getMonth() + 1 == closedDates[i][1] &&
                        date.getFullYear() == closedDates[i][2]) {

                  return [false, '']; // Closed date
            }
      }
      return [day > 0, '']; // Open if not Sunday
}
                                            

Open in new window

0
BrighteyesDesign
Asked:
BrighteyesDesign
  • 2
1 Solution
 
Robert SchuttSoftware EngineerCommented:
Can you show more code or a link to a live page?

Without testing, if this works in your current code to disable Sundays...
return [day > 0, '']; // Open if not Sunday

Open in new window

...then I would expect it works for you if you replace that line with:
return [day == 1, '']; // Open if Monday

Open in new window

0
 
Robert SchuttSoftware EngineerCommented:
Now I tested it, with the JQuery UI datepicker, and it works.
captureEDIT: also put it on my website to test directly: http://schutt.nl/ee/Q_28308112/
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now