1

我有以下(工作)JavaScript 日期选择器。“out”mindate 等于 1。如何使“out”mindate 等于我的访问者选择的日期和今天的日期之间的差异,而不是 1?

$(function() { var dateSelected = false;

$( "#in" ).datepicker({
    minDate: 0,
    defaultDate: "+1w",
    changeMonth: true,
    numberOfMonths: 3,
    onClose: function(dateText, inst) {
        dateSelected = true;

    }
});

$('form').submit(function(){
    if (!dateSelected) {
        alert('Please Enter start Dates');
    }
    return dateSelected;
});
});

$(function() { var dateSelected = false;


$( "#out" ).datepicker({
    minDate: 1,
    defaultDate: "+1w",
    changeMonth: true,
    numberOfMonths: 3,
    onClose: function(dateText, inst) {
        dateSelected = true;

    }
});
$('form').submit(function(){
    if (!dateSelected) {
        alert('Please Enter end Dates');
    }
    return dateSelected;
});
});

谢谢你的热心帮助。

4

1 回答 1

0

要在这样的日子里获得过期日期和日期之间的差异:

var nDifference = Math.abs(new Date($("#in").val()) - new Date());
var one_day = 1000 * 60 * 60 * 24;
var days = Math.round(nDifference / one_day);

并设置最小日期,如:

minDate: days;​
于 2012-12-28T14:34:59.447 回答