views:

919

answers:

3

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.

+3  A: 

Use the minDate option to set the minimum possible date. http://jqueryui.com/demos/datepicker/#option-minDate

Bill
+1: I've used minDate and maxDate to set a valid date interval and it works like a charm.
Jim Ferrans
A: 

You just need to specify a minimum date - setting it to 0 means that the minimum date is 0 days from today i.e. today. You could pass the string '0d' instead (the default unit is days).

$(function () {
    $('#date').datepicker({ minDate: 0 });
});
Russ Cam
A: 

try using startDate and set it to the current date. $('.date-pick').datePicker({startDate:'01/01/1996'});

mikell