简体   繁体   English

禁用引导日期选择器中的日期自动格式化

[英]Disable Auto formatting of date in bootstrap datepicker

Am having issue where if someone enters an invalid date manually such as "%/4/12" into the datepicker it will autoformat it to "04/12/2017" or if you enter "12/123/20258" it formats to '12/12/2025 which I don't want. 如果有人手动在日期选择器中输入无效的日期(例如“%/ 4/12”),它将自动将其格式化为“ 04/12/2017”,或者如果您输入“ 12/123/20258”,则将其格式化为“ 2025年12月12日,我不要。 Is there any way to disable this? 有什么办法可以禁用此功能? Here is what I already have: 这是我已经拥有的:

$(function () {
        $('#new-effective-date').datetimepicker({
            format: 'MM/DD/YYYY',
            defaultDate: false,
            useCurrent: false,
            keepInvalid: true
        });
    });

Add: 加:

useStrict useStrict

http://eonasdan.github.io/bootstrap-datetimepicker/Options/#usestrict http://eonasdan.github.io/bootstrap-datetimepicker/Options/#usestrict

and Change your codes to this: 并将您的代码更改为此:

$(function () {
        $('#new-effective-date').datetimepicker({
            format: 'MM/DD/YYYY',
            useStrict: true,
        keepInvalid: true,
        });
    });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM