简体   繁体   English

如何禁用datePicker的自动填充功能

[英]how to disable datePicker's autofill feature

I'm using datepicker (datepicker.min.js) in my JSP. 我在JSP中使用datepicker(datepicker.min.js)。 http://freqdec.github.io/datePicker/ http://freqdec.github.io/datePicker/

When I input 01/01/17, it will automatically fill it as 01/01/2017 in chrome and 01/01/1917 in IE. 当我输入01/01/17时,它将自动将其填充为Chrome中的01/01/2017和IE中的01/01/1917。

Does anybody know how to disable this feature? 有人知道如何禁用此功能吗?

I hope that I input 01/01/17 and get 01/01/17 instead of 01/01/2017 or 01/01/1917. 我希望我输入01/01/17并获得01/01/17而不是01/01/2017或01/01/1917。

Based on the documentation, it looks like you should initialize your datepicker with: 根据文档,您似乎应该使用以下命令初始化datepicker:

datePickerController.createDatePicker({
    formElements:{
        'date-picker-id': '%m/%d/%y'
    }
});

%y is for a 2 digit representation of the year. %y是年份的2位数字表示。 See Date formats section for details. 有关详细信息,请参见日期格式部分。

You can just remove the default behaviour of the datepicker in the change event, from the documentation you can use their addEvent(obj, type, fn) function, or just stick with the defaule addEventListener function. 你可以只取出日期选择器的默认行为的change情况,从文档,你可以使用自己addEvent(obj, type, fn)功能,或者只是坚持与defaule addEventListener功能。

Your code will be like this: 您的代码将如下所示:

addEvent(datePickerController, "change", function(e){
     e.preventDefault();
});

They provide also an option to remove any event, you can use the removeEvent(obj, type, fn) function. 它们还提供了删除任何事件的选项,您可以使用removeEvent(obj, type, fn)函数。

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

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