Topic: Date picker: Cannot scroll throug all years
fredemagi pro asked 5 years ago
Expected behavior
I want a user to be able to select all years in the year range in the date picker.
Actual behavior
A user can only choose 15 in the range. Say the range goes from 2001 - 1987, the user would first have to click on 1987, and then he would click the list again and could now select down to 1980. How to I modify the code so a user can select from all years and don't have to click multiple times to get to the right year?
Code snippet
var dateObj = new Date();
var currentDay = dateObj.getUTCDate();
var currentMonth = dateObj.getUTCMonth();
var currentYear = dateObj.getUTCFullYear();
var maxYear = currentYear - 18;
var minYear = currentYear - 100;
$('#datepicker').pickadate({
monthsFull: ['Januar', 'Februar', 'Marts', 'April', 'Maj', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'December'],
monthsShort: ['Jan', 'Feb', 'Mar', 'Apr', 'Maj', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dec'],
weekdaysFull: ['Søndag', 'Mandag', 'Tirsdag', 'Onsdag', 'Torsdag', 'Fredag', 'Lørdag'],
weekdaysShort: ['Søn', 'Man', 'Tir', 'Ons', 'Tor', 'Fre', 'Lør'],
today: undefined,
clear: 'Slet',
close: 'Luk',
labelMonthNext: 'Næste måned',
labelMonthPrev: 'Forrige måned',
labelMonthSelect: 'Vælg måned',
labelYearSelect: 'Vælg år',
format: 'dd/mm-yyyy',
formatSubmit: 'yyyy-mm-dd',
firstDay: 1,
hiddenName: true,
min: new Date(minYear, currentMonth, currentDay),
max: new Date(maxYear, currentMonth, currentDay)
});
Closed
This topic is closed.
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Closed
- ForumUser: Pro
- Premium support: No
- Technology: MDB jQuery
- MDB Version: 4.7.5
- Device: Computer
- Browser: Google Chrome
- OS: Windows 10
- Provided sample code: No
- Provided link: No
fredemagi pro commented 5 years ago
Never mind. Found the solution here: https://mdbootstrap.com/support/jquery/datepicker-number-of-years-in-drop-down-limited-to-15/