I have two inputs. I want to limit date ranges to 3 days. Once selected, other dates will become inactive. How can I do?
Asked
Active
Viewed 25 times
1 Answers
0
This solution allows to select only three days on 3 datepickers. You can easily adapt this solution to two different datepicker elements.
/* Allows the date to be the maximum today. */
datePickerId.max = new Date().toISOString().split("T")[0];
/* Allows the date to be a minimum of 3 days ago. */
var date = new Date();
date.setDate(date.getDate() - 3);
datePickerId.min = date.toISOString().split("T")[0];
<input type="date" id="datePickerId" />

Sercan
- 4,739
- 3
- 17
- 36