Home > Back-end >  Max Date based on another input
Max Date based on another input

Time:10-27

I'm using 'Pickaday Js' library for dates.

I have html like this

<input class="today" type="date" id="today">
<input class="another_day" type="date" id="another_day">

I have javascript like this

var today = new Pikaday({
   field: document.getElementById("today"),
   minDate: new Date(),
});
var another_day = new Pikaday({
   field: document.getElementById("another_day"),
   minDate: new Date(),
   maxDate: today.value   15 // I want the max date to be the today input date   15 days
});

Can someone help me achieve this?

CodePudding user response:

Resolved.

var another_day = new Pikaday({
   field: document.getElementById("another_day"),
   minDate: new Date(),
   new Date(new Date(document.getElementById("today").value).getTime() (15*24*60*60*1000)) // Added 15 days to input today
});
  • Related