Is there a way to initialize the date picker so that the user can only pick a year and not a specific day or month?
Yup, that’s totally possible!
You need to use the dateWheels
option, explained here: https://docs.mobiscroll.com/jquery/datetime#localization-dateWheels.
Like this: dateWheels: 'yy'
.
Let me know how it goes
Well, that sounds promising but I can’t get it to work. Here’s my code.
$(function(){
$('#pageyear').mobiscroll().calendar({
'focusOnClose':false,
'defaultValue':'<?php echo $currentyear; ?>',
dateWheels: 'yy'
});
});
But it still pops up with a regular calendar. What am I doing wrong?
Hello Vincent
Ok, now I got it!
The problem is that you can’t set a yer only picker in the Calendar.
But a solution could be to use the Date & Time picker component.
In that component you can achieve this easily with dateWheels
option, as I mentioned earlier.
Example:
$('#demo').mobiscroll().date({
dateWheels: 'yy',
dateFormat: 'yy',
});
Let me know if this make sense.
Yes, that works. Thanks!