JQuery UI Datepicker - disable today's date if today is Monday?

jQuery UI Datepicker:

Hello,

I am trying to have a pop-up calendar that allows me to select only Monday dates in the future. I tried this code:

$(function() { $('#dateWeekly').datepicker({ showOn: 'both', // use to enable calendar button and focus buttonImage: 'childtime/images/calendar.gif', buttonImageOnly: true, buttonText: 'Show Calendar', numberOfMonths: 3, showButtonPanel: true, minDate: -0, maxDate: '+12M', // beforeShowDay: function(date){ return [date.getDay() == 1,""]} beforeShowDay: function(date) { return [date.getDay() == 1, "" && date.getTime() != today.getTime(), ""]; } }); }); 

This disables all past dates and disables all future days except Monday (so far so good), but today it is not possible to disable today's date if today is Monday. Any suggestions would be appreciated. Thanks!

0
source share
3 answers

Set minDate to +1d .

Since you should only choose the future of Monday, today should not be chosen, no matter what day it will be.

And you can simplify your beforeShowDay to:

 beforeShowDay: function(date) { return [date.getDay() == 1, ""]; } 
0
source

Below code may be the solution to this issue.

  beforeShowDay: function(date) { returnFlag = true; currentDate = new Date(); if( date.getDay() == 1 && date.getDate() == currentDate.getDate() && date.getMonth() == currentDate.getMonth()){ returnFlag = false; } return [returnFlag,'',false]; } 
0
source

Maybe it will help

 $(function() { $('#dateWeekly').datepicker({ showOn: 'both', // use to enable calendar button and focus buttonImage: 'childtime/images/calendar.gif', buttonImageOnly: true, buttonText: 'Show Calendar', numberOfMonths: 3, showButtonPanel: true, minDate: -0, maxDate: '+12M', beforeShowDay: function(date) { // from here var selectable = true; var today = new Date() if( today.getDay() == 1 && date.getDate() == today.getDate() )selectable = false; return [selectable,'',false]; // til here } }); }); 
-1
source

All Articles