![](/img/trans.png)
[英]How to prevent from manually changing the date greater than max-date for uib-datepicker
[英]How can I show a date on a kendo datepicker which is less than min date or greater than max date
如何在劍道日期選擇器上設置一個日期(例如,1/1/2012),該日期小於在日期選擇器選項中定義的最小日期(例如,1/1/2013)或大於最大日期(例如,1/1/2014) ?
我的要求是將用戶的選擇限制在最小值和最大值之間,但是我希望日期選擇器顯示超出該范圍的值(例如,如果該值在數據庫中被覆蓋)。
如果使用以下min
和max
選項創建日期選擇器:
var datePicker = $('#input').kendoDatePicker({
min: new Date(2013, 0, 1),
max: new Date(2013, 11, 31)
}).data("kendoDatePicker");
那么您就不能在該日期范圍之外設置值。 您可以創建自己的小部件,也可以暫時刪除最小/最大限制以設置值:
// temporarily remove the restrictions
var min = datePicker.options.min;
var max = datePicker.options.max;
datePicker.options.min = new Date(1900, 0, 1);
datePicker.options.max = new Date(2099, 11, 31);
// set your date which may be outside of the range specified by min/max
datePicker.value(new Date(2009, 0, 1));
// restore the min/max options so the user still can only choose within the range
datePicker.options.min = min;
datePicker.options.max = max;
因此,您需要能夠在日期選擇器中選擇一個無效的日期,但是如果它是一個無效的日期,則會顯示一條錯誤消息。
聽起來好像您的日期選擇器需要一個kendo驗證器小部件。 Kendo驗證程序文檔http://docs.kendoui.com/api/framework/validator
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.