Donate

Set jQuery UI DatePicker To Current Month And Below

Hi All,
Here's how to set the jQuery UI DatePicker calendar dates to current month and below it. Future months are disregarded. The fix is to set the maxDate property with the current year, next month (current month + 1) and 0 for the day to get the last date of current month.
var date = new Date();
$("#datepicker").datepicker({
  dateFormat: 'yy-mm-dd ',
  changeMonth: true,
  changeYear: true,
  maxDate: new Date(date.getFullYear(), date.getMonth() + 1, 0)
}); 
Output
Set jQuery UI DatePicker To Current Month And Below
Note: As you can see from the image above, the next month button is disabled.

Cheers!

Comments

Donate

Popular Posts From This Blog

WPF CRUD Application Using DataGrid, MVVM Pattern, Entity Framework, And C#.NET

TypeScript Error Or Bug: The term 'tsc' is not recognized as the name of a cmdlet, function, script file, or operable program.

Invalid nested tag div found, expected closing tag input