4

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"
    });
});​
Antonio Laguna
  • 8,137
  • 7
  • 31
  • 68
Mladen
  • 367
  • 6
  • 18
  • 2
    [Works for me](http://jsfiddle.net/Anxea/). The year selection menu only shows +/-10 years from the current selection, but you can select multiple times to go further back up to the 65 years specified. – Jon May 24 '12 at 10:27
  • Thanks for that, but I really need for that whole range to show in the year drop down, not just the 10 years. Any ideas? – Mladen May 24 '12 at 10:32

2 Answers2

6

You can use yearRange option for that;

$('#datepicker').datepicker({
    changeMonth: true,
    changeYear: true,
    yearRange: "-65y:-18y"
});
Emre Erkan
  • 8,282
  • 3
  • 46
  • 52
5

This works for me;

$("#txt_birthdate").datepicker({
  yearRange: "-100:-18",
  changeMonth: true,
  changeYear: true,
  maxDate: new Date()
});
Emre Erkan
  • 8,282
  • 3
  • 46
  • 52
DadViegas
  • 2,143
  • 14
  • 12
  • This is the answer I was looking for, thanks a lot. All I needed to do was to set a yearRange. I was just confused by the example they gave in the help section of the datepicker website, I thought you would have to specify the years, didn't know it can be a flexible range set based on todays date. Apologies to all if I was unclear when asking the question! – Mladen May 24 '12 at 10:36