jQuery UI 日期选择器范围 [英] jQuery UI Datepicker Range
问题描述
几天前我问了一个非常相似的问题,但这是足够不同,我不想让另一个有用的话题脱轨.我基本上想设置两个文本输入字段并将它们与 jQuery UI 的 Datepicker 连接起来,让它们充当一个范围......我希望第二个输入字段的开始日期取决于您在第一个输入中选择的内容场地.例如,如果我为第一个字段选择 10-25-2010,那么您可以在第二个字段中选择的最早日期应该是 10-26-2010.任何有关此主题的帮助或指导将不胜感激!
I asked a pretty similar question a few days ago, but this one is different enough that I didn't feel like derailing the other helpful topic. I basically want to set up two text input fields and hook them both up with jQuery UI's Datepicker to have them act as a range... I want the second input field start date to be contingent upon what you've selected in the first input field. For instance if I select 10-25-2010 for the first field, then the earliest day you can select in the second field should be 10-26-2010. Any help or direction on this topic would be greatly appreciated!
推荐答案
$(function() {
$('#txtStartDate, #txtEndDate').datepicker({
showOn: "both",
beforeShow: customRange,
dateFormat: "dd M yy",
});
});
function customRange(input) {
if (input.id == 'txtEndDate') {
var minDate = new Date($('#txtStartDate').val());
minDate.setDate(minDate.getDate() + 1)
return {
minDate: minDate
};
}
}
这篇关于jQuery UI 日期选择器范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!