cesarcarlos
cesarcarlos

Reputation: 1409

JQuery datepicker minDate shows the date before the minimum set

We want users to pick any date starting Nov. 30, 2020. I'm using the following script to set up the minDate on the JQuery datepicker.

$(function() {
  $( "#datepicker" ).datepicker({
    dateFormat: "yy-mm-dd",
    minDate: new Date('2020-11-30'),
  });
});

The problem is that when I try the picker, the first date available is November 29 instead of November 30.

datepicker image

I have tried setting different dates but the previous date is always available. However, if I set the date to 2020-12-1 then it works.

What am I missing?

Upvotes: 0

Views: 397

Answers (1)

John Clinton
John Clinton

Reputation: 214

try using this:

$(document).ready(function(){
   $( "#datepicker" ).datepicker({
      dateFormat: "yy-mm-dd",
      startDate: new Date('2020-11-30')
    });
});

Upvotes: 1

Related Questions