Solved

Disable all days except monday on js calendar

Posted on 2013-12-02
2
299 Views
Last Modified: 2013-12-02
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
Comment
Question by:BrighteyesDesign
  • 2
2 Comments
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 500 total points
ID: 39690510
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
 
LVL 35

Expert Comment

by:Robert Schutt
ID: 39690573
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now