ling.s ling.s - 2 months ago 6x
HTML Question

JQuery datepicker yearrange

I have 2 datepickers like this

<input type="text" class="datepicker" data-year-range="2010:2016"/>
<input type="text" class="datepicker" data-year-range="2000:2020"/>

I have to define the
for the 2 datepickers in configuration. So, I did like this.

changeYear: true,
// $(this) isn't working here
//yearRange : $(this).attr('data-year-range'),
yearRange : $('.datepicker').attr('data-year-range')

But it is taking only
for the two datepickers. I don't understand why. The idea is to use different date ranges for the datepickers. Is it possible or do I need to define different datepickers?

Also, In datepickers is it possible to add the
in html instead of the datepicker configuration?

Here is the fiddle


You can do it in following way:

$(document).ready(function() {
     $('.datepicker').each(function() {
         changeYear: true,
         yearRange: $(this).data('year-range'),