简体   繁体   English

过去的日期没有隐藏在日期选择器中?

[英]past dates are not hiding in date picker?

Hello Everyone I'm beginner in Jquery and javascript.In my project I have to use bootstrap.I have tried to execute datepicker to hide past datesDate picker is working even though past dates are not hiding..I have attached the below the code.. 大家好,我是Jquery和javascript的初学者。在我的项目中,我必须使用bootstrap。我试图执行datepicker来隐藏过去的日期即使没有隐藏过去的日期,日期选择器仍在工作。.我在下面的代码中附加了代码。 。

 <!--html:--> <div class="form-group"> <div class="col-sm-3 control-label"> <label for="FromDate" class="control-label">FromDate:</label> </div> <div class="col-sm-4"> <div class="input-group date"> <div class="input-group-addon"> <i class="fa fa-calendar"></i> </div> <input type="text" name="fromDate" id="fromDate" class="form-control pull-right" data-validation-engine="validate[required]" /> </div> </div> </div> <div class="form-group"> <div class="col-sm-3 control-label"> <label for="ToDate">ToDate:</label> </div> <div class="col-sm-4"> <div class="input-group date"> <div class="input-group-addon"> <i class="fa fa-calendar"></i> </div> <input type="text" name="toDate" id="toDate" class="form-control pull-right" data-validation-engine="validate[required]" onchange="report();" /> </div> </div> </div> <!--script:--> <script type="text/javascript" th:inline="javascript"> /*<![CDATA[*/ // Date picker $('#fromDate').datepicker({ autoclose: true, todayHighlight: true, format: 'dd-M-yyyy' }); $('#toDate').datepicker({ autoclose: true, todayHighlight: true, format: 'dd-M-yyyy' }); $('#fromDate').datepicker({ minDate: new Date() }); $('#toDate').datepicker({ minDate: new Date() }); /*]]>*/ </script> 

Thanks!! 谢谢!!

var dateToday = new Date();
var dates = $("#from, #to").datepicker({
    defaultDate: "+1w",
    changeMonth: true,
    numberOfMonths: 3,
    minDate: dateToday,
    onSelect: function(selectedDate) {
        var option = this.id == "from" ? "minDate" : "maxDate",
            instance = $(this).data("datepicker"),
            date = $.datepicker.parseDate(instance.settings.dateFormat || $.datepicker._defaults.dateFormat, selectedDate, instance.settings);
        dates.not(this).datepicker("option", option, date);
    }
});

Try the above piece of code 试试上面的代码

I replicated your code and it is working fine. 我复制了您的代码,它工作正常。

Can be more clear on the versions and packages you use. 可以更清楚地了解您使用的版本和软件包。

For Datepicker which package you use. 对于Datepicker,您使用哪个软件包。 I used jquery ui For bootstrap you have used v3 (which is not a consideration here), but the latest version is 4 我使用了jQuery ui进行引导,您使用的是v3(此处未考虑),但最新版本为4

http://jsfiddle.net/0oL2yh6r/1/ http://jsfiddle.net/0oL2yh6r/1/

jQuery(document).ready(function(){
    $( "#fromDate" ).datepicker({
    minDate: new Date(),
   autoclose : true,
          todayHighlight : true,
          format : 'dd-M-yyyy'
  });
});

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在引导日期选择器中禁用过去的日期 - Disable past dates in bootstrap date picker React Semantic Date Picker 禁用选择过去的日期 - React Semantic Date Picker disable select past dates 日期和时间选择器,禁用将来和过去的日期和时间 - Date and Time picker with disable future and past dates and times 如何编写脚本来限制过去日期的 Ninja Form 日期选择器? - How to write a script to restrict Ninja Form date picker for past dates? 如何在引导程序日期选择器中显示过去的日期以供选择? - How to show past dates for selection in bootstrap date picker? 如何在javascript / jquery中的日期选择器中禁用日历中的过去日期? - How to disable past dates in calendar in date-picker in javascript/jquery? ACF 日期选择器从前端删除过去的日期 - ACF Date picker remove past dates from front end 如何在react-bootstrap-date-picker节点模块上禁用react js的过去和今天的日期? - how to disable past and today dates on react-bootstrap-date-picker node module for react js? 如何在日期选择器上禁用过去的日期。尝试了stackoverflow提供的所有解决方案 - How to disable the past dates on the date picker .Tried all solutions provided on stackoverflow 过去日期的日期范围逻辑 - Date range logic for past dates
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM