In this post I will share a simple technique to disable past dates in Jquery DatePicker.
Use the following snippet and it will set today as the minimum selectable date.
$("#datepicker").datepicker({ minDate:0});
The minDate parameter is used to set a minimum selectable date. Passing ‘0’ will tell datepicker to set minimum selectable date ‘0’ days from today. In other words, it disable all past dates.
Similarly passing ‘5’ will set minimum date as 5 days from today.
Another point to note is that the calendar picks todays date from system’s settings. So users in different timezones might get different minimum selectable date.
Update: We have posted a more thorough guide on disabling dates in jQuery DatePicker.
Thank you for such awesome post.You saved my hours.Keep writing such awesome articles in such easy language
SIR YOUR WORK IS AMAZING.BUT I WANT TO ASK..WHAT IF I WANT TO DISABLE A SPECIFIC DATE INCLUDING ITS PREVIOUS DATES?
Thanks a lot dude, but there is one problem it omit the datepicker formating
$(“#datepicker”).datepicker({ minDate:0});
$( “#datepicker” ).datepicker({ dateFormat: “mm/d/yy” });
formating will appear as 01/01/2018 … while i want to omit 0 …
Any suggestion
Sir your work is really amazing. Could you please tell me that how do i disable date later than today’s date?
I want to disable the previous dates from datepicker. Can you correct this code?
$(function () {
$(“#datetimepicker2″).datetimepicker({format:’YYYY-MM-DD’});
});