我的Php-Mysql应用程序需要允许并在UI中设置一些无效日期,例如mysql默认日期,registry。
当我尝试在Bootstrap DateTime小部件中执行此操作时,它的确似乎删除了0000-00-00,并变成了空字段。我的代码如下
//do the dates now
$("#date").datetimepicker({
format: "YYYY-MM-DD",
icons: {
time: "fa fa-clock-o",
date: "fa fa-calendar",
up: "fa fa-chevron-up",
down: "fa fa-chevron-down",
previous: "fa fa-chevron-left",
next: "fa fa-chevron-right",
today: "fa fa-screenshot",
clear: "fa fa-trash",
close: "fa fa-remove"
}
});
如何添加/允许用户输入无效日期(例如“ 0000-00-00”)的选项?
答案 0 :(得分:1)
实际上,如果这是您想要的,那么可以很容易地将通讯录作为输入日期。 引导程序日期选择器提供了一个选项,该选项为 forceParse: false
将此选项设置为false会为您带来所有神奇效果,但默认情况下为true,但请注意,价格昂贵;):)
Type: Boolean
Default: true
Whether or not to force parsing of the input value when the picker is closed. That is, when an invalid date is left in the input field by the user, the picker will forcibly parse that value, and set the input’s value to the new, valid date, conforming to the given format.
将此选项设置为 false ,以允许输入任何错误的日期
来源:https://bootstrap-datepicker.readthedocs.io/en/stable/options.html#forceparse