jQuery datepicker to prevent past date

netrox picture netrox · Nov 23, 2009 · Viewed 154.6k times · Source

How do I disable past dates on jQuery datepicker? I looked for options but don't seem to find anything that indicates the ability to disable past dates.

UPDATE: Thanks yall for the quick response. I tried that with no luck. Days were still not grayed out as I expected and still accept the selected past date.

I tried this:

$('#datepicker').datepicker({ minDate: '0' });

Doesn't work.

I tried this:

$('#datepicker').datepicker({ minDate: new Date() });

Still doesn't work either.

It displays the calendar widget just fine. It just won't gray out or prevent input of past days. I've attempted the minDate and maxDate in the past with no luck so I figured it must not be them.

Answer

Khawar picture Khawar · Jun 27, 2011

Try this:

$("#datepicker").datepicker({ minDate: 0 });

Remove the quotes from 0.