You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Metronic主题date-picker双击年份显示负数值的解决方法

Metronic主题Date-Picker双击年份出现负数值问题解决

我在HTML中使用如下日期选择器:

<input class="form-control m-input date-picker" id="ItemSerial_EffectiveDateValue" type="text" name="effectiveDate" value="@Model.ItemSerial.EffectiveDate" />

点击输入框可正常显示日历,但双击年份值时会出现-2021这类负年份数值。

我先后尝试了以下两段JavaScript配置,均无法解决问题:

第一段配置:

$('.date-picker').datetimepicker({  
    format: 'MM/DD/YYYY', 
    minDate: '1900-01-01',  
    useCurrent: false, // Prevents auto-setting to current date/time on error  
    viewMode: 'days'
});

第二段配置:

$('.date-picker').datepicker({
    format: 'mm/dd/yyyy',
    startDate: '01/01/1900',
    endDate: '12/31/2030',
    autoclose: true,
    todayHighlight: true
});

经排查发现这是Metronic主题date-picker的CSS问题,最终通过以下CSS代码解决了该问题:

.bootstrap-datetimepicker-widget .datepicker-years thead,
.bootstrap-datetimepicker-widget .datepicker-years .disabled {
    display: none;
}

内容的提问来源于stack exchange,提问作者user123456

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.11 15:32:37