【问题标题】:How to disable the future dates in datepicker using angularjs and jquery如何使用 angularjs 和 jquery 在 datepicker 中禁用未来日期
【发布时间】:2017-08-08 16:40:24
【问题描述】:

您好,我需要禁用未来的日期,我已经尝试了所有方法 但我无法请让我知道我错在哪里。

<div class="input-group date">
     <input type="text" class="form-control pull-right" id="datepicker2" placeholder="Date of Join" ng-model="DateofJoining">
     <div class="input-group-addon"></div>
</div>

$('#datepicker2').datepicker({
    autoclose: true,
    maxDate: new Date()
});

我什至也尝试过使用 angularjs,但无法禁用它们,请告诉我如何禁用未来的日期。

我正在使用 bootstrap-datepicker.js 来创建日期选择器。

【问题讨论】:

    标签: jquery angularjs datepicker


    【解决方案1】:

    我的主要建议是使用@krix 建议的角度指令

    无论如何,您可以根据您的代码输入禁用未来日期,如下所示

    $(document).ready(function() {
        $('.datepicker').datepicker({
            format: 'mm-dd-yyyy',
            endDate: '+0d',
        });
    });
    <script type="text/javascript" src="//code.jquery.com/jquery-1.8.3.js"></script>
    <link rel="stylesheet" type="text/css" href="http://www.eyecon.ro/bootstrap-datepicker/css/datepicker.css">
    <link rel="stylesheet" type="text/css" href="http://getbootstrap.com/dist/css/bootstrap.min.css">
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.4/js/bootstrap-datepicker.min.js"></script>
    
    <input class="datepicker" />

    【讨论】:

      【解决方案2】:

      我建议使用 UI Bootstrap 中的日期选择器:

      https://angular-ui.github.io/bootstrap/#!#datepicker

      类似于 Bootstrap 指令,但为 AngularJS 重新构建。

      【讨论】:

        【解决方案3】:
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2011-04-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-10-14
        相关资源
        最近更新 更多