How to disable past dates in Jquery Datepicker

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.

About Ankit

Founder of Spice Forms.
Spice Form is a Drag n Drop tool to create powerful web forms in minutes.

Comments

  1. rais ahmad says:

    Thank you for such awesome post.You saved my hours.Keep writing such awesome articles in such easy language :)

  2. SIR YOUR WORK IS AMAZING.BUT I WANT TO ASK..WHAT IF I WANT TO DISABLE A SPECIFIC DATE INCLUDING ITS PREVIOUS DATES?

  3. 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

  4. rupinder kaur says:

    Sir your work is really amazing. Could you please tell me that how do i disable date later than today’s date?

Trackbacks

  1. […] my last post I talked about how you can disable past dates in Jquery datepicker. In this post I will discuss […]

Speak Your Mind

*