我正在研究剑道日期时间选择器。点击提交按钮时出现问题。 1)有日期和日期选择器。如何获得应该验证日期和时间的弹出窗口,它不应该允许字母表。
$("#startdatetimepicker").kendoDateTimePicker({
showSecond: true,
dateFormat: "dd-mm-yy",
timeFormat: "HH:mm:ss",
format: "dd-MM-yy HH:mm:ss",
mindate: getFormattedDate(new Date())
}).data("kendoDateTimePicker");
$("#startdatetimepic").attr("readonly", "readonly");
function getFormattedDate(date) {
alert("")
var day = date.getDate();
var month = date.getMonth() + 1;
var year = date.getFullYear().toString().slice(2);
return day + '-' + month + '-' + year;
}
$("#enddatetimepicker").kendoDateTimePicker({
showSecond: true,
dateFormat: "dd-mm-yy",
timeFormat: "HH:mm:ss",
format: "dd-MM-yy HH:mm:ss"
}).data("kendoDateTimePicker");
var result = $("#grid").kendoGrid({
filterable: true,
columns: [{
field: "FirstName",
title: "First Name"
}, {
field: "LastName",
title: "Last Name"
}, {
field: "dob",
title: "DOB",
format: "{0:dd-MM-yy HH:mm:ss}"
}],
dataSource: {
data: [ {
FirstName: "Joe",
LastName: "Smith",
dob: "2013-02-01 19:54:13"
}, {
FirstName: "Jane",
LastName: "Smith",
dob: "2013-02-02 20:55:14"
}, {
FirstName: "Jane",
LastName: "Smith",
dob: "2013-02-03 21:56:15"
},
{
FirstName: "Jane",
LastName: "Smith",
dob: "2013-03-4 20:56:14"
}],
schema: {
data: function (data) {
$.each(data, function (i, val) {
val.dob = kendo.parseDate(val.dob, "yyyy-MM-dd HH:mm:ss");
});
return data;
}
}
}
}).data("kendoGrid");
$("#filter").on("click", function () {
var mindate = $('#startdatetimepicker').data("kendoDateTimePicker").value();
var maxdate = $('#enddatetimepicker').data("kendoDateTimePicker").value();
var condition = {
logic: "and",
filters: []
};
if (mindate !== null) {
condition.filters.push({
field: "dob",
operator: "ge",
value: mindate
});
}
if (maxdate !== null) {
condition.filters.push({
field: "dob",
operator: "le",
value: maxdate
});
}
result.dataSource.filter(condition);
});
here is the fiddle:http://jsfiddle.net/5bchz/97/
答案 0 :(得分:0)
格式应该禁止字母字符,而增加值可以实现类似于:
function incrementDay(increment) {
var datePicker = $("#DayPager").data("kendoDatePicker");
var val = datePicker.value();
var newDate = new Date(val.getFullYear(), val.getMonth(), val.getDate() + increment);
datePicker.value(newDate);
}