moe
moe

Reputation: 5249

how to restrict dates in datepicker using jquery

I am trying to restrict the dates in the date picker and would like to make available only for 2012 and 2013 in the date-picker. how would i do that? I am not sure the syntax of j-query so i can restrict it. thanks this is what i have so far. here is my j-query

   <script type="text/javascript">
             $(document).ready(function () {
                 $('.datepicker').datepicker({ minDate: -20, maxDate: "+1M +10D" });
             });
    </script>

Upvotes: 0

Views: 1668

Answers (1)

kronion
kronion

Reputation: 711

You should assign Date objects to the two fields:

$('.datepicker').datepicker({ minDate: new Date(2012, 0, 1) , maxDate: new Date(2013, 11, 31) });

Upvotes: 2

Related Questions