簡體   English   中英

如何在日期選擇器中禁用今天之前的日期

[英]how to disable date before today in datepicker

我想禁用今天之前的日期。(例如,今天的日期是04Oct17,我希望禁用此日期之前的所有日期,但仍允許用戶使用以前的月份,年份等)。

 $(document).ready(function () {
     var date_input = $('input[name="date"]'); //our date input has the name "date"
     var container = $('.bootstrap-iso form').length > 0 ? $('.bootstrap-iso form').parent() : "body";
     var options = { 
      format: 'mm/dd/yyyy',
      container: container,
      todayHighlight: true,
      autoclose: true,
 };
      date_input.datepicker(options);
 })

在日期選擇器選項中添加minDate

 var dateToday = new Date(); // Today's Date.
 var options = { 
  format: 'mm/dd/yyyy',
  container: container,
  todayHighlight: true,
  autoclose: true,
  minDate:dateToday // <--- this will disable all date less then dateToday
 };
 date_input.datepicker(options);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM