0

Hi I have a issue with the jQuery datepicker.

Tried to search post but cannot get any solution yet. I am trying to implement the jQuery datepicker to disable specific date with the below code. But instead of disable that specific dates, I need the following is also disable. Let, if I disable 20-01-2016, the 21-01-2016 will also automatic disabled.

Anyone can help please?

 var disabledDays = ["8-5-2016","8-25-2016"]; function nationalDays(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 || new Date() > date) { return [false]; } } return [true]; } function noWeekendsOrHolidays(date) { var noWeekend = jQuery.datepicker.noWeekends(date); return noWeekend[0] ? nationalDays(date) : noWeekend; } $( "#step3a" ).datepicker({ showButtonPanel: true, changeMonth: true, changeYear: true, dateFormat: "yy-mm-dd", minDate: +2, beforeShowDay: noWeekendsOrHolidays }); 
9
  • Please read this : stackoverflow.com/questions/9742289/… Commented Aug 3, 2016 at 7:11
  • Hi Vijay, yes the disabled date is added in the array. But how we can make also the date disable itself but also disabled the following 1 days. Because I dont want to add the following date disabled by calling again it in the array. Commented Aug 4, 2016 at 6:47
  • So you want to enable that date when date picker open again, right? Commented Aug 4, 2016 at 7:04
  • Hi Vijay, not so. What I need is eg:, if we put the var disabledDays = ["8-5-2016","8-25-2016"]; the follow date for these 2 dates, "8-6-2016" and "8-26-2016" will be disabled too. As what we need is when a specific date is disabled, it will disabled for 2 days always. Commented Aug 4, 2016 at 8:59
  • you need to disabled for 8-6-2016.17..... and so on right? If yes then please remove year from array e.g. var yourArray=['8-6','8-26'] Commented Aug 4, 2016 at 9:32

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.