[英]How to disable previous date in datepicker
在下面的代碼中,我正在使用太平洋/奧克蘭的時區作為其今天的時區日期,即2017年4月11日完成,現在的日期是2017年4月12日,但是在我的日期選擇器中4月11日未禁用。 我需要禁用以前的日期,即2017年4月11日。
這是我的日期選擇器代碼
.datepicker({
autoclose: true,
todayHighlight: true,
startDate: new Date().toLocaleString('en-NZ', { timeZone: 'Pacific/Auckland' })
})
您只需在startDate屬性中從今天的date(new Date())開始一天就可以做到這一點。
嘗試從客戶端今天的日期中減去一天;
.datepicker({
autoclose: true,
todayHighlight: true,
startDate: new Date().setDate(new Date().getDate()-1).toLocaleString('en-NZ', { timeZone: 'Pacific/Auckland' })
})
minDate選項是您要尋找的。
.datepicker({
autoclose: true,
todayHighlight: true,
minDate: new Date().setDate(new Date().getDate()-1).toLocaleString('en-NZ', { timeZone: 'Pacific/Auckland' })
})
您將必須使用minDate
創建它:
.datepicker({
autoclose: true,
todayHighlight: true,
minDate: // whatever you choose,
startDate: new Date().setDate(new Date().getDate()-1).toLocaleString('en-NZ', { timeZone: 'Pacific/Auckland' })
})
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.