jquery datepicker - 不要在今天之前用其他检查显示日期

时间:2015-10-08 01:39:58

标签: javascript jquery datepicker

我有一个jquery datepicker,我想不允许以前的日期(以及只有特定的日期)

 $(function() {
    $( "#datepicker" ).datepicker({beforeShowDay: function(date){
        var day = date.getDay();
        var today = new Date();
        return [
        (
    day > today  -- HOW TO DO THIS LINE
 &&

        day != <?php echo $dateday[0];?>
        && 
        day != <?php echo $dateday[1];?>
        && 
        day != <?php echo $dateday[2];?>
        &&
        day != <?php echo $dateday[3];?>
        && 
        day != <?php echo $dateday[4];?>
        && 
        day != <?php echo $dateday[5];?>
        && 
        day != <?php echo $dateday[6];?>
        ),''];
    }
    });
  });

1 个答案:

答案 0 :(得分:0)

添加&#39; minDate&#39; dataepicker的选项。

var dateToday = new Date();
var dates = $("#from, #to").datepicker({
  minDate: dateToday
});

代码示例 - http://jsfiddle.net/nicolapeluchetti/dAyzq/1/