我正在使用此datepicker代码,我想从datepicker
中禁用以前的日期 <script type="text/javascript">
new datepickr('datepick');
new datepickr('datepick1');
new datepickr('datepick2', {
'dateFormat': 'm/d/y'
});
new datepickr('datepick3', {
'fullCurrentMonth': false,
'dateFormat': 'l, F j'
});
new datepickr('datepick4', {
dateFormat: '\\l\\e jS F Y', /* need to double escape characters that you don't want formatted */
weekdays: ['dimanche', 'lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi'],
months: ['janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre'],
suffix: { 1: 'er' },
defaultSuffix: '' /* the suffix that is used if nothing matches the suffix object, default 'th' */
});
</script>
<link rel="stylesheet" type="text/css" href="date/datepickr.css" />
<script type="text/javascript" src="date/datepickr.min.js"></script>
<input id="datepick" class="text_field datepicker" name="fromdate" required="required" />
任何有关停用上一个日期的帮助将不胜感激。
答案 0 :(得分:0)
var todayDate = new Date().toISOString().split('T')[0];
document.getElementsByName("myDate")[0].setAttribute('min', todayDate);
$(".book_btn").click(function(){
var today = new Date();
var date = today.getFullYear()+'-'+("0" +(today.getMonth()+1)).slice(-2)+'-'+("0" + today.getDate()).slice(-2);
//alert(date);//("0" + this.getDate()).slice(-2)
document.getElementById("myDate").defaultValue =date;
});<style type="text/css">
input[type=date]::-webkit-inner-spin-button {
-webkit-appearance: none;
display: none;
}
</style>