Solved

Disable all days except monday on js calendar

Posted on 2013-12-02
2
310 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

707 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