Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery Datepicker minDate not working

I would expect the following would have the date range to start from 65 years ago and end at 18 years ago. Instead, minDate number is ignored, and set to 10 years prior to end date. No difference whatever I put as value in minDate.

$(function() {
    $("#datepicker").datepicker({
        changeMonth: true,
        changeYear: true,
        minDate: "-65y",
        maxDate: "-18y"
    });
});​
like image 670
Mladen Avatar asked Dec 21 '22 21:12

Mladen


2 Answers

You can use yearRange option for that;

$('#datepicker').datepicker({
    changeMonth: true,
    changeYear: true,
    yearRange: "-65y:-18y"
});
like image 147
Emre Erkan Avatar answered Dec 26 '22 20:12

Emre Erkan


This works for me;

$("#txt_birthdate").datepicker({
  yearRange: "-100:-18",
  changeMonth: true,
  changeYear: true,
  maxDate: new Date()
});
like image 20
DadViegas Avatar answered Dec 26 '22 21:12

DadViegas