在bootstrap datepicker日历中禁用日期范围之后的未来日期

时间:2017-03-01 08:21:47

标签: jquery twitter-bootstrap datepicker

 [[ARAPIKey sharedInstance] setAPIKey:@"sVmoznmKZ+4nFEHD6HoslwpC26PNuBZGHrikUwyon2BKSvza1yu2CqbSrae+pHPr1NHjhsf5pHQOZn8IEqXlqXFodGsrOJhxJANbMOdvnRLUi9/QWGqyRL9FViDmyohw6e5R7U4Ex8H7d7spLLvhfp5HFv56DgLr8c8sC2ipDtv9g1IjOTaY7UGxata3eulG2A/UkIdRv2NcotZXqan01xQUWFAislEwlGguParEYiwu11T4mqtU3dQBbfxpvxbczjdYz493YG3rAO2RHgT+5M5TJShJsz2irkNo71JD2Fzqf4AR2b4+7t1c55zKjegXzGS6Xa/rpNn9yiXUn7rUYIHNvN3cEQa9HsZiVxAV4vJgxFS+T/AxfWqKrEg1uj6xF5MsodZ2EkZ8mqliYIsxZqnFz+Re2HeWG8wvrEob0ZwRIO0TxppAemZc3HChTAPLcNt5gzeBk0oRP4wnrFAFFBDi8XjDocwTSVw++hWZb1qNHzt6bKLsMDRT057UVuuZB6M8f7EOQD79Oah0Vrx/3DUK6e9BEV8oGFNHtk1wyYEkg0i6RLhVSokGx//Qj36A4gCz3h1OjtfB0OuukbNq7xI1L/FcNQLmGYNGZwszARjGr9ESw1gVAkbQMxaV27uo/KoIq4+nR7RL8iT7t7NAaXCFIi24RR+7WGjTvKqWYjA="];

我想在日期选择范围后禁用所有日期。 E.G.-我将选择开始日期1 feb所以到目前为止将自动填充7 feb.I想要在7 feb之后所有日期将被禁用。所有这些功能都需要在jquery日历中引导日历。

1 个答案:

答案 0 :(得分:0)

这是你需要做的。为changeDate撰写#from - datepicker个活动,并使用setStartDatesetEndDatesetDate等选项添加+6天,从日期开始选择。

$("#from").datepicker({
  startDate: new Date() 
}).on('changeDate',function(e){
    var newDate=new Date();//get today's date instance
    newDate.setDate(e.date.getDate()+6); //add selected from date + 6 to today's date
    $("#to").datepicker('setDate',newDate); //setDate of to
    $("#to").datepicker('setEndDate',newDate);//setEndDate of to
    $("#to").datepicker('setStartDate',e.date);//setStartDate of to
});
$("#to").datepicker();

<强> Fiddle Here