5

I have to disable the dates between today's date to selected(set) date. Here is my code

$(function () {
    $("#departure").datepicker({
        dateFormat: "dd/mm/yy",
        changeMonth: true,
        changeYear: true,
        maxDate: "+5",
         minDate: -0
    });
    $("#departure").datepicker("setDate", "5");
});
<input id="departure" />

here is my screenshot:- enter image description here

Now I want to diable date 5 6 7 means 3 days after today. please help me.....

Hello I got my answer perfectly, But one issue came if in 5 days,if there is weekends it should be skip so what to do for that any body knows suppose today is 11-6-2013 then 15 and 16 should be skip and 19th date would come.

User1988
  • 1,965
  • 4
  • 25
  • 47

3 Answers3

1

This is my answer Today is 11-6-2013

 $("#departure").datepicker({
        dateFormat: "dd/mm/yy",
        changeMonth: true,
        changeYear: true,
        maxDate: "+1y",
         minDate: +4,
    });
 $("#departure").datepicker("setDate", "5");
<input id="departure" />

enter image description here

User1988
  • 1,965
  • 4
  • 25
  • 47
0

yes you can specify one array as range to disable like this way

// Disable a list of dates
var disabledDays = ["9-21-2010", "9-24-2010", "9-27-2010", "9-28-2010", "9-3-2010", "9-17-2010", "9-2-2010", "9-3-2010", "9-4-2010", "9-5-2010"];
function disableAllTheseDays(date) {
    var m = date.getMonth(), d = date.getDate(), y = date.getFullYear();
    for (i = 0; i < disabledDays.length; i++) {
        if($.inArray((m+1) + '-' + d + '-' + y,disabledDays) != -1) {
            return [false];
        }
    }
    return [true];
}
$('#datepicker5').datepicker({
        dateFormat: 'mm-dd-yy',
        beforeShowDay: disableAllTheseDays
});

Here i am posing very useful LINK to disable any dates or any date range.

let me know if i can help you more.

liyakat
  • 11,825
  • 2
  • 40
  • 46
  • is it not fixed that this much date should be disable. from today ,3 date should be disable.@liyakat – User1988 Jun 04 '13 at 10:23
  • but you can assign it to javascript variable from PHP. to make one array when page is load. – liyakat Jun 04 '13 at 10:26
  • suppose your selected date is before 3 days and current date you will get from date() function. find date between those days using phg and make array of string like as above in js file. – liyakat Jun 04 '13 at 10:31
  • also please check http://stackoverflow.com/questions/4312439/php-return-all-dates-between-two-dates-in-an-array to get array of range between 2 – liyakat Jun 04 '13 at 10:31
  • if my answer is helpful to you please dont forget to accept and vote up. so in future for same problem. other person can easily solve it – liyakat Jun 04 '13 at 10:33
  • and one more easy function to generate array with your require date format just use this : http://www.rarst.net/script/php-date-range/ – liyakat Jun 04 '13 at 10:37