如何限制未来日期的引导日期选择器 [英] how to restrict bootstrap date picker from future date

查看:111
本文介绍了如何限制未来日期的引导日期选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想限制引导的日期选择器从未来的日期。我只想启用迄今为止的日期。如何实现这一点。

I want to restrict the date picker of bootstrap from taking future date.I just want to enable the dates up to today only.How can i achieve this.

这是我的代码

<script>
  var FromEndDate = new Date();

    $(function(){
   $('.datepicker').datepicker({
      format: 'mm-dd-yyyy',
     endDate: FromEndDate, 
    autoclose: true
    });
});
</script>

任何身体帮助这个

推荐答案

这是一个工作解决方案的演示:

Here is a demo of a working solution:

http://jsfiddle.net/tjnicolaides/cjp7y/

<script>
$(function(){
    $('.datepicker').datepicker({
        format: 'mm-dd-yyyy',
        endDate: '+0d',
        autoclose: true
    });
});
</script>

编辑:支持startDate和endDate的Bootstrap Datepicker版本在这里: https://github.com/eternicode/bootstrap-datepicker

edit: the version of Bootstrap Datepicker that supports startDate and endDate is here: https://github.com/eternicode/bootstrap-datepicker

原始项目,这是当前顶尖的插件搜索结果,目前还没有此功能: http://www.eyecon.ro / bootstrap-datepicker /

The original project, which is the current top search result for the plugin, does not have that feature at this time: http://www.eyecon.ro/bootstrap-datepicker/

这篇关于如何限制未来日期的引导日期选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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