如何限制 Bootstrap Datepicker 中的可选日期范围? [英] How to restrict the selectable date ranges in Bootstrap Datepicker?

查看:30
本文介绍了如何限制 Bootstrap Datepicker 中的可选日期范围?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用 datepicker,它为我提供了限制可选日期的选项.我们一直在使用 jQuery UI,它使用 minDate、maxDate 选项来支持它.

I need to use datepicker which provides me the option of restricting the selectable dates. We had been using jQuery UI which is used to support it using minDate, maxDate options.

$("#id_date").datepicker({minDate: +1, maxDate: '+1M +10D'}); 

最近我们开始为我们的样式使用 Twitter Bootstrap.显然,Twitter Bootstrap 与 jQuery UI 样式不兼容.所以我尝试使用 http://www.eyecon.ro/bootstrap-日期选择器/.

Recently we started using Twitter Bootstrap for our styles. And apparently, Twitter Bootstrap is incompatible with jQuery UI styles. So I tried using one of the bootstrap compatible datepickers available at http://www.eyecon.ro/bootstrap-datepicker/.

不幸的是,上面的插件不像 jQuery UI 的日期选择器那样可配置.任何人都可以帮助我限制新日期选择器中的可选日期范围.

Unfortunately, the above plugin is not as configurable as jQuery UI's datepicker. Can anyone help me out with restricting the selectable date ranges in the new datepicker.

推荐答案

Bootstrap datepicker 能够设置日期范围.但它在初始版本/主分支中不可用.在那里检查分支为范围"(或仅在 https://github.com/eternicode/bootstrap-datepicker 处查看)),您只需使用 startDate 和 endDate 即可.

The Bootstrap datepicker is able to set date-range. But it is not available in the initial release/Master Branch. Check the branch as 'range' there (or just see at https://github.com/eternicode/bootstrap-datepicker), you can do it simply with startDate and endDate.

示例:

$('#datepicker').datepicker({
    startDate: '-2m',
    endDate: '+2d'
});

这篇关于如何限制 Bootstrap Datepicker 中的可选日期范围?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆