[英]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.