Form Control Date Time Picker Range Issue

Nishant Khandelwal asked on January 2, 2017 16:21

Hi,

I used date picker form control for birth date but it is only showing range 2007-2027.

How can I change range?

Recent Answers


Brenden Kehren answered on January 2, 2017 17:11 (last edited on January 2, 2017 17:12)

The control is dynamic in nature meaning if you select 2010, it will show 10 years before and 10 years after so the list isn't huge. In my test, I selected 2007 and when it updated, the list then had years in there from 1997 to 2017. So not ideal in your case but if you let them enter their own date, it will validate it as well.

Other option is to create your own form control or use another calendar implementation for a selector.

1 votesVote for this answer Mark as a Correct answer

Michal Samuhel answered on January 3, 2017 11:40

Hi Nishant,

We are using jquery datetimepicker, which is using preset range of years, although you can customize it very quickly since range of +/- 10 years is just hardcoded in it. This is in jquery-ui-datetimepicker in CMSScripts/jquery folder on line cca 380(depending on version), where you can set up the range you need:

yearRange: 'c-10:c+10', // Range of years to display in drop-down,
            // either relative to today's year (-nn:+nn), relative to currently displayed year
            // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
1 votesVote for this answer Mark as a Correct answer

Juraj Ondrus answered on January 3, 2017 11:53

Hi,
In addition to what Brenden said, you can follow this old, but still accurate article: Adding years to calendar.
This change will affect all the calendars used in the system and also, you need to keep this in mind when upgrading or hotfixing.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.