4

Hi I am using pickdate and I am having field this in my view :

<%= f.text_field :date_of_birth,:placeholder =>'Select Date',
                     :class => 'datepicker picker_input' %>

So in this I have this jquery

$('.datepicker').pickadate({
            format: 'dd/mm/yyyy',
            selectMonths: true,
            selectYears: 60
    });

So it gives me years from 1985 to 2045 but I want years from 1945 to current_year. How to fetch this with the help of pickadate. Please guide me. Thanks in advance.

Dinshaw Raje
  • 933
  • 1
  • 12
  • 33

4 Answers4

11

Try setting the max option to true

$('.datepicker').pickadate({
  format: 'dd/mm/yyyy',
  selectMonths: true,
  selectYears: 60,
  max: true
});
Rajdeep Singh
  • 17,621
  • 6
  • 53
  • 78
2

Try this;

$('.datepicker').pickadate({
            format: 'dd/mm/yyyy',
            selectMonths: true,
            selectYears: 70,
            max: true
    });
Vrushali Pawar
  • 3,753
  • 1
  • 13
  • 22
  • If you just set max true option and won't change selectYears value then it will display years from 1955 and you can check this – Vrushali Pawar May 26 '15 at 08:11
1
$('.datepicker').pickadate({
  format: 'dd/mm/yyyy',
  selectMonths: true,
  min: new Date(1945,1,1),
  max: true
});

try using min so you would have more control over the minimum year range you wanted without worrying if the selectYear still reaches the current year

geek_10101010
  • 90
  • 1
  • 4
  • 19
-1
$(function() {
    $( ".datepicker" ).datepicker({
      changeMonth: true,
      changeYear: true,
      yearRange: '1945:'+(new Date).getFullYear()         
    });
});
shajeer
  • 50
  • 3