开始日期和结束日期datepicker
问题描述:
我有输入日期,其中包含开始日期和结束日期以过滤期间。我想让开始日期是今天的日期,结束日期与开始日期或开始日期之后的一天相同。条件是如果我在01-04-2017选择开始日期,我可以选择01-04-2017或在结束日期输入之后的日期。开始日期和结束日期datepicker
这就是我所做的,但仍然没有给出最好的答案。
<div class="col-md-4">
<div class="input-group input-daterange">
<input type="text" name="from_date_alt" id="from_date_alt" class="form-control datepicker" placeholder="Start date" value="">
<span class="input-group-addon">to</span>
<input type="text" name="to_date_alt" id="to_date_alt" class="form-control datepicker" placeholder="End date" value="">
</div>
</div>
这是脚本。
var nowDate = new Date();
var today = new Date(nowDate.getFullYear(), nowDate.getMonth(), nowDate.getDate(), 0, 0, 0, 0);
$(".datepicker").datepicker({
format: 'yyyy-mm-dd',
startDate: today,
autoclose: true
});
我该怎么做?
答
$(function() {
$("#datepicker").datepicker("option", "minDate", new Date(2017, 3 - 1, 31));
});
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$(function() {
$("#datepicker").datepicker();
});
</script>
<p>Date: <input type="text" id="datepicker"></p>
我不明白,这样的事情?