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

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

问题描述

我想限制引导程序的日期选择器获取未来日期.我只想启用截至今天的日期.我怎样才能做到这一点.

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>

任何机构都可以对此提供帮助

Can any body help regarding this

推荐答案

这是一个可行的解决方案演示:

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-日期选择器

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天全站免登陆