Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Disable all days except monday on js calendar

Posted on 2013-12-02
2
Medium Priority
?
324 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 2000 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

636 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