I'm new to JavaScript. So please don't go harsh on me.
After the StartDate gets selected, the ExpectedEndDate and the EndDate must start with StartDate + 1 day and end in 6 months. Other dates must be disabled in the ExpectedEndDate and EndDate.
Here the futureInput.Max works fine. But the futureInput.Min doesn't work. I couldn't find where it went wrong.
$(document).ready(()=>{
var startInput = $('#StartDate')[0];
var expectedEndInput = $('#ExpectedEndDate')[0];
var endInput = $('#EndDate')[0];
startInput.addEventListener('change', (evt)=>{
var EndTime = new Date($("#StartDate").val());
var dd = String(EndTime.getDate() + 1);
var mm = String(EndTime.getMonth() + 6);
var yyyy = EndTime.getFullYear();
var MaxTime = yyyy + '-' + mm + '-' + dd;
var StartTime = new Date($("#StartDate").val());
var dd = String(StartTime.getDate() + 1);
var mm = String(StartTime.getMonth() + 1);
var yyyy = StartTime.getFullYear();
var MinTime = yyyy + '-' + mm + '-' + dd;
debugger
[expectedEndInput, endInput].forEach((futureInput)=> {
futureInput.min = MinTime;
futureInput.max = MaxTime;
debugger
})
})
})
<link href="https://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css" rel="stylesheet">
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script src="https://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<input type="date" id="StartDate" />
<input type="date" id="ExpectedEndDate" />
<input type="date" id="EndDate" />