1

I have two inputs. I want to limit date ranges to 3 days. Once selected, other dates will become inactive. How can I do?

enter image description here

enter image description here

Sercan
  • 4,739
  • 3
  • 17
  • 36

1 Answers1

0

This solution allows to select only three days on 3 datepickers. You can easily adapt this solution to two different datepicker elements.

enter image description here

/* 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