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

查看:1122
本文介绍了如何限制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 -datepicker /

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的datepicker那么配置。任何人都可以通过限制新日期戳中的可选日期范围来帮助我。

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.

推荐答案

引导日期戳可以设置日期 - 范围。但是在初始版本/主分支中不可用。将分支检查为范围(或仅在 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天全站免登陆