大家好,我正在使用trentrichardson.com提供的datetimepicker。
我有一个表单,其中包含两个输入字段:起始日期和结束日期,我希望能够动态设置“结束日期”字段的最小日期等于“起始日期”字段的值。
我知道应该使用beforeShow选项,但不知道如何实现该功能。
$('.from,.to').datetimepicker({
beforeShow: customRange
});
编辑/解决方案
function customRange(input) {
if (input.id == 'to') {
var x=$('#from').datepicker("getDate");
$( ".to" ).datepicker( "option", "minDate",x );
}
else if (input.id == 'from') {
var x=$('#to').datepicker("getDate");
$( ".from" ).datepicker( "option", "maxDate",x );
} }