Reputation: 48736
I am trying to create a DatePicker out of a textbox using jQuery. I have the following code:
$(function() {
$("#ctl00_ContentPlaceHolder1_txtServiceDateRequested").datepicker({
showAnim: "puff",
minDate: new Date(2013,10,23)
});
});
I am trying to make it so that dates prior to 10/23/2013 can not be selected. Using this code though, for some reason, its disabling all days prior to 11/23/2013 (November instead of October). Does anyone have any thoughts? Am I using the minDate
property wrong?
Upvotes: 0
Views: 101
Reputation: 30310
If you configure minDate
with a Date
, then @j08691 is exactly right. Months are 0-based. That's a JavaScript thing rather than a Datepicker thing.
Still as the documentation shows, you can use a string too if it is formatted properly (according to the dateFormat
option). That could help you get it right too in a more intuitive way.
Upvotes: 0
Reputation: 208002
Months in JavaScript are zero based, so January is zero, February is one, etc. So October is actually 9, not 10.
Use minDate: new Date(2013,9,23)
See also: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
month: Integer value representing the month, beginning with 0 for January to 11 for December.
Upvotes: 3