【发布时间】:2017-03-21 14:19:17
【问题描述】:
我必须填写开始日期和结束日期。如何设置结束日期,用户只能从开始日期开始选择日期,就像在屏幕中一样
这是我的 js,我在其中为我的输入调用数据选择器
$(document).ready(function () { var $task_executions_from_date = $('#task_executions_from_date');
$task_executions_from_date.datepicker({
dateFormat: 'dd.mm.yy'
});
$task_executions_from_date.on('change', function () {
var test = $task_executions_from_date.val();
console.log(test);
});
var $task_executions_to_date = $('#task_executions_to_date');
$task_executions_to_date.datepicker({
dateFormat: 'dd.mm.yy',
beforeShowDay: function(date){
var arrayDate = $task_executions_from_date.val().split('.');
var start_date = new Date(arrayDate[2], arrayDate[1]-1, arrayDate[0]).getTime();
if (start_date) {
return date.getTime() > start_date;
}
return true;
}
});
beforeShowDay 需要为 task_executions_to_date.datepicker 输入什么?就像所有的日子which > test
现在我把所有日期都禁用了,为什么不明白
【问题讨论】:
-
ok
beforeShowDay可见日期,但如何从start_date中选择日期并创建包含所有日期的数组 > 从start_date中选择日期? -
只用
.val()读取字段值。 -
我得到开始日期` $task_executions_from_date.on('change', function () { var test = $task_executions_from_date.val(); console.log(test); }); ` 如何选择所有测试的日期?
-
我更新了我的问题
标签: jquery arrays datepicker jquery-ui-datepicker