Reputation: 8116
I am running Bootstrap 3.3.6 (latest) and Datepicker plugin 1.6.0 (latest).
I want the date box to only accept and display year between a certain range (in my current case 2014, 2015, and 2016).
I have this customization in place:
$('#my-container .my-class').datepicker({
//format: " yyyy", // does not work
minViewMode: "years",
maxViewMode: "years",
startDate: '01/01/2014',
endDate: new Date(),
startView: "year" //does not work
});
Is it possible to limit the input and display to just a 4-digit year?
Upvotes: 2
Views: 8547
Reputation: 5714
Try this solution :
$('.datepicker').datepicker({
autoclose: true,
format: " yyyy",
viewMode: "years",
minViewMode: "years",
startDate: '2014',
endDate: new Date(),
});
See JsFiddle. I hope it works for you, thanks.
Upvotes: 3