How can I set the minDate/maxDate for jQueryUI Datepicker using a string?

Posted by leo on Stack Overflow See other posts from Stack Overflow or by leo
Published on 2010-05-04T22:11:24Z Indexed on 2010/05/11 15:54 UTC
Read the original article Hit count: 317

Filed under:
|
|
|
|

jQueryUI Datepicker documentation states that the minDate option can be set using "a string in the current dateFormat". So I've tried the following to initialize datepickers:

$("input.date").datepicker({ minDate: "01/01/2010", maxDate: "12/31/2010" });

However, this results in my datepicker having a selectable date range that goes from 11/06/2015 to 12/17/2015.

I've checked the current dateformat and its mm/dd/yy, which is supposed to mean 2 digits for the month, 2 for the day, and 4 for the year, separated by slashes. I've also tried including dateFormat: "mm/dd/yy" in the inizialization statement.

I've also checked the values for minDate and maxDate afterwards and they ARE being set to the values I want: 01/01/2010 and 12/31/2010.

I want to be able to set min/maxDate with strings because I'm being passed these values as strings from somewhere else. Maybe someone knows why this happens and how to solve this, or a workaround to achieve this, perphaps changing the format of the date strings or something?

Thanks

EDIT: Using: jQuery v1.3.2 and jQuery UI v1.7.2

© Stack Overflow or respective owner

Related posts about jquery-ui

Related posts about datepicker