bootstrap-datepicker学習のoptions
4882 ワード
$('#id').datepicker({
format: 'yyyy/mm/dd', //
container: 'body', // , body , css
autoclose: true, //
forceParse: true, //
maxViewMode: 4, // , 0( )、 、 、 、4( )。
minViewMode: 0, //
startView: 0, // , ,
multidate: false, //
multidateSeparator: ',' //
language: 'zh-CN', // locales zh-CN.js
clearBtn: false, //
todayBtn: true, //
showWeekDays: true, //
weekStart: 0,// ,0
todayHighlight: false, //
keyboardNavigation: true, //
disableTouchKeyboard: false, // , .
calendarWeeks: false, //
assumeNearbyYear: true, // 15 2015,97 1997; 20 20
datesDisabled: ['2019/04/10', '2019/04/11'], // , , , format .
daysOfWeekDisabled: [], // , , 0( ) 6( ), '06' '0,6' [0,6]
daysOfWeekHighlighted: [0, 6], // , daysOfWeekDisabled .
defaultViewDate: new Date(2019, 1, 1), // , , date, ( format ), ( year: ,month:0( ),day:1( ))
beforeShowDay: function (date) {
// , beforeShowDay ;
// , css class ,
var newDate = new Date(date);
var today = new Date();
if (today.toLocaleDateString() == newDate.toLocaleDateString()) {
return {
enabled: true, //
classes: 'calendarStyle', // date class ,
tooltip: 'xxx', // title , xxx title , ( , )
content: ' ' // date ,
}
}
},
beforeShowMonth: function (date) {
// beforeShowMonth , 12 .
var newDate = new Date(date);
var today = new Date();
if (newDate.getMonth() == today.getMonth()) {
return {
enabled: true, //
classes: 'calendarStyle', // , ,
tooltip: 'xxx' //
}
}
},
beforeShowYear: function (date) {
// beforeShowYear
// 1 0 9 12 。
// 2019 (2018 ), 2010-2019 2009 2020 12
var newDate = new Date(date);
var today = new Date();
if (newDate.getFullYear() == today.getFullYear()) {
return {
enabled: true, //
classes: 'calendarStyle', // , ,
tooltip: 'xxx' //
}
}
},
beforeShowDecade: function (date) {
// 12 , 00 90 10 10
// 2019 , 2000,2010,2020...2090, 1990,2100 12
var newDate = new Date(date);
var today = new Date();
if (newDate.getFullYear() < today.getFullYear()) {
return {
enabled: true, //
classes: 'calendarStyle', // , ,
tooltip: 'xxx' //
}
}
},
beforeShowCentury: function (date) {
// 12 , 000 900 100 100
// 2019 , 2000,2100,2200...2900, 1900,3000 12
var newDate = new Date(date);
var today = new Date();
if (newDate.getFullYear() == parseInt(today.getFullYear() / 100) * 100) {
return {
enabled: true, //
classes: 'calendarStyle', // , ,
tooltip: 'xxx' //
}
}
},
startDate: '2019/04/01', //
endDate: new Date(Date.now() - 864000000), // date ,
enableOnReadonly: true, // :true, ,
immediateUpdates: true, // , false, , , .
});