我有一个日期选择器,当我选择“FROM”日期时,它应该在“FROM”datepicker中自动禁用所选日期之前的所有日期。有什么帮助吗?
答案 0 :(得分:2)
试试这个:http://jsfiddle.net/kZBEt/447/
startDate:<div class="datepickerFrom"></div>
<br /><br /><br /><br />
end Date:<div class="datepickerTill"></div>
<script type="text/javascript">
$( ".datepickerFrom" ).datepicker({
inline: true,
altField: "#dateFrom",
dateFormat: "dd.mm.yy",
minDate: 0,
onSelect: function (date) {
var date2 = $(".datepickerFrom").datepicker("getDate");
date2.setDate(date2.getDate() + 1);
$(".datepickerTill").datepicker("setDate", date2);
$(".datepickerTill").datepicker("option", "minDate", date2);
}
});
$( ".datepickerTill" ).datepicker({
inline: true,
altField: "#dateTill",
dateFormat: "dd.mm.yy",
minDate: 1
});
$("#dateFrom").change(function(){
$(".datePickerTill").datepicker("setDate", $(this).val());
});
</script>