How can i disable past date with my codes with real time?
<div class="form-group">
<label>Check-In</label>
<input name="cin" type ="date" class="form-control">
</div>
<div class="form-group">
<label>Check-Out</label>
<input name="cout" type ="date" class="form-control">
</div>
You can make it disallow any previous date by using JavaScript a little bit and the min
attribute:
let [today] = new Date().toISOString().split("T"); document.querySelector("input").setAttribute("min", today);
<input name="cin" type ="date" class="form-control">
This will update automatically. If you don't want to allow any checkins earlier than a fixed date (let's say New Year's Day 2019) then just set the min
attribute manually:
<input name="cin" type ="date" class="form-control" min="2019-01-01">
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.