1. Localization
can load the file directly, or add the following statement directly after the script
jQuery(function ($) {
$.datepicker.regional['zh-CN'] = {
closeText: 'Close',
prevText: 'nextText: 'Next month>',
currentText: 'Today',
monthNames: ['January', 'February', 'March', 'April', ' May', 'June',
'July', 'August', 'September', 'October', 'November', 'December'],
monthNamesShort: ['one', 'two', 'three', 'four', 'five', 'six',
'seven', 'eight', 'nine', 'ten', 'eleven', ' Twelve'],
dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
dayNamesShort: ['Sunday ', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
dayNamesMin: ['Day', 'Monday', 'Two', 'Wednesday' ', '四', '五', '六'],
weekHeader: 'week',
dateFormat: 'yy-mm-dd',
firstDay: 1,
isRTL: false ,
showMonthAfterYear: true,
yearSuffix: 'year'
};
$.datepicker.setDefaults($.datepicker.regional['zh-CN']);
});
2. Click Today to display the date directly in the input, instead of jumping to today's place and requiring the user to click the date again. The modification method is very simple, add this code in the script
$.datepicker._gotoToday = function (id) {
var target = $(id);
var inst = this._getInst(target[0]);
if (this._get(inst, 'gotoCurrent') && inst.currentDay) {
inst.selectedDay = inst.currentDay;
inst.drawMonth = inst.selectedMonth = inst.currentMonth;
inst.drawYear = inst.selectedYear = inst.currentYear;
}
else {
var date = new Date();
inst.selectedDay = date.getDate();
inst.drawMonth = inst.selectedMonth = date.getMonth();
inst.drawYear = inst.selectedYear = date .getFullYear();
this._setDateDatepicker(target, date);
this._selectDate(id, this._getDateDatepicker(target));
}
this._notifyChange(inst);
this._adjustDate(target);
}