datepicker disable futures dates and display today date as default date

44 Views Asked by At

I would like to display today's date in my datapicker and in the same time disable future dates. For the moment I can only do one option, I can just disable future dates or I can display today's date.

here is my code:

  $('#datepicker').datepicker({
                format: "dd-mm-yyyy",
                endDate: today,
            });
  $('#datepicker').datepicker('setDate', new Date());
1

There are 1 best solutions below

0
Sangeetha Krishna On

$( "#datepicker" ).datepicker({
dateFormat:"dd-mm-yy",
maxDate : new Date()
});

MaxDate helps you to limit the future dates