0

Web html css js

How disable past dates in fisrt input date and disable (date from first date) in second input date ????

19th Sep 2020, 11:27 AM
Oussama MOUSSIOU
Oussama MOUSSIOU - avatar
1 ответ
+ 1
It sounds like you want to make a date range selector and adjust the min and max for each input to push the user into a sensible date range. Here is a working example of how that could be implemented: <html> <head> <script> document.addEventListener('DOMContentLoaded', function() { var fromDate = document.getElementById('from-date'); var toDate = document.getElementById('to-date'); fromDate.addEventListener('change', function() { toDate.setAttribute('min', fromDate.value); }); toDate.addEventListener('change', function() { fromDate.setAttribute('max', toDate.value); }); }); </script> </head> <body> <label for="from-date">From</label> <input id="from-date" type="date"> <label for="to-date">To</label> <input id="to-date" type="date"> </body> </html>
19th Sep 2020, 5:25 PM
Josh Greig
Josh Greig - avatar