简体   繁体   中英

Set start date and restrict dates in datepicker

I am trying to set start date to 14 days from today. Below 14 days date will not be selectable. I also need to lock the next 13 days as not selectable.

 $('#sandbox-container input').datepicker({ format: 'mm/dd/yyyy', keyboardNavigation: false, forceParse: false, startDate: new Date(), autoclose: true }) 
 <input type="text" name="productDate" id="productDate" class="form-control" maxlength="20" placeholder="Date" value="{{ date('m/d/Y',strtotime($productDate))}}"> 

 var newdate = new Date(); newdate.setDate(newdate.getDate() - 14); $('input').datepicker({ format: 'mm/dd/yyyy', keyboardNavigation: false, forceParse: false, minDate: newdate, startDate: newdate, autoclose: true }) 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/datepicker/0.5.4/datepicker.min.js"></script> <link href="https://cdnjs.cloudflare.com/ajax/libs/datepicker/0.5.4/datepicker.min.css" rel="stylesheet"/> <input type="text" name="productDate" id="productDate" class="form-control" maxlength="20" placeholder="Date" value=""> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM