Solved

JavaScript Calendar Popup

Posted on 2009-05-08
6
1,449 Views
Last Modified: 2012-05-06
Hi,

I am using the CalendarPopup.js available at http://www.mattkruse.com/javascript/calendarpopup/ in order to provide a popup calendar in a form.  Everything is working well but I can't seem to work out how to disable dates 1 week ahead of the current date.  

I have currently managed to get it to allow selection of the days in the week I want and also I have disabled every date before the current date.  But now I am looking to get it to disable selection of any of the selectable days 1 week ahead of the current date.

I hope this makes sense, and thank you in advance for any assistance.
var now  = new Date();

var cal1 = new CalendarPopup("caldiv");

cal1.showNavigationDropdowns();

cal1.setCssPrefix("TEST");

cal1.setDisabledWeekDays(0,2,3,4,5,6);

cal1.addDisabledDates(null,formatDate(now,"yyyy-MM-dd"));

cal1.addDisabledDates("01/01/2007");

Open in new window

0
Comment
Question by:john_hollings
  • 3
  • 3
6 Comments
 
LVL 12

Expert Comment

by:Gibu George
Comment Utility
cal1.addDisabledDates(formatDate(now.getDate()-1,"yyyy-MM-dd"));
cal1.addDisabledDates(null,formatDate(now.getDate()+8,"yyyy-MM-dd"));
0
 
LVL 5

Author Comment

by:john_hollings
Comment Utility
Hi I did try something similar to this, however I used the code you supplied and I got the same result, it just allows me to select previous dates which I am also need disabled.
<script language="JavaScript">

	var now  = new Date();

	var cal1 = new CalendarPopup("caldiv");

	cal1.showNavigationDropdowns();

	cal1.setCssPrefix("TEST");

	cal1.setDisabledWeekDays(0,2,3,4,5,6);

	cal1.addDisabledDates(formatDate(now.getDate()-1,"yyyy-MM-dd"));

	cal1.addDisabledDates(null,formatDate(now.getDate()+8,"yyyy-MM-dd"));

	cal1.addDisabledDates("01/01/2007");

</script>

Open in new window

0
 
LVL 12

Accepted Solution

by:
Gibu George earned 500 total points
Comment Utility
cal1.addDisabledDates(null,formatDate(now.getDate()-1,"yyyy-MM-dd"));
cal1.addDisabledDates(formatDate(now.getDate()+8,"yyyy-MM-dd"),null);

0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 12

Expert Comment

by:Gibu George
Comment Utility
This is the correct one. I got it wrong the first time
0
 
LVL 5

Author Comment

by:john_hollings
Comment Utility
OK thanks for the updated code.  Forgot to bring the laptop home for the weekend so will get back to you on Monday and let you know how I get on.
0
 
LVL 5

Author Comment

by:john_hollings
Comment Utility
Hi,

Still hasn't disabled the week ahead of today's date.  I attached the code I used.
	var now  = new Date();

	var cal1 = new CalendarPopup("caldiv");

	cal1.showNavigationDropdowns();

	cal1.setCssPrefix("TEST");

	cal1.setDisabledWeekDays(0,2,3,4,5,6);

	cal1.addDisabledDates("01/01/2007");

	cal1.addDisabledDates(null,formatDate(now.getDate()-1,"yyyy-MM-dd"));

	cal1.addDisabledDates(formatDate(now.getDate()+8,"yyyy-MM-dd"),null);

Open in new window

0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
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…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

763 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

13 Experts available now in Live!

Get 1:1 Help Now