javascript中的日期选择器,不接受过去和当前日期

时间:2011-07-07 01:59:29

标签: javascript

这是我的代码:

<script type="text/javascript" src="calendar_date_picker.js"></script>
<script type="text/javascript">
  var cdp1 = new CalendarDatePicker();
  var props = {
    debug :         true,
    excludeDays :       [6,0,1],
    excludeDates :      ['20081225','20081226','20091225','20091226'],
    minimumFutureDate : 5,
    formatDate :        '%m-%d-%y'
  };
  var cdp2 = new CalendarDatePicker(props);
  props.formatDate = '%d-%m-%y';
  var cdp3 = new CalendarDatePicker(props);
  cdp3.endYear = cdp3.startYear + 1;
  var cdp4 = new CalendarDatePicker(props);
  cdp4.addDisabledDatas("new Date =< new Date");
</script>

2 个答案:

答案 0 :(得分:1)

尝试:

 var props = {
    debug :         true,
    excludeDays :       [6,0,1],
    excludeDates :      ['20081225','20081226','20091225','20091226'],
    minimumFutureDate : [5, false],
    formatDate :        '%m-%d-%y'
    };

来自文档:

minimumDate - 此日期之前的日期不可选。格式:yyyymmdd
maximumDate - 此日期之后的日期不可选。格式:yyyymmdd
minimumFutureDate - 与最小日期相同,但定义为当前日期的偏移量。必须设置为一个数组,其中第二个参数表明是否应该考虑排除的日期

http://devshed.excudo.net/scripts/javascript/source/calendar+date+picker

答案 1 :(得分:-1)

另请看这个页面: http://devshed.excudo.net/scripts/javascript/calendar_date_picker_help.php

它包含您可以修改的所有属性的列表。您可能还对startYear属性感兴趣