I want to create a function that takes as parameter the id of my input tag and checks the following cases: 1 - The date entered must be in the future (The date entered cannot be in the past) 2 - The date entered must not be greater than 6 months
this is my code
<body>
<h1>Check user date value</h1>
a: <input type="date" name="dateResName" id="dateResId" required/>
<input type ="button" value="Check Date User" onclick= "checkUserDate(document.getElementById('dateResId').value);" >
<script>
function checkUserDate(dtUser) {
var today = new Date();
var d = new Date(dtUser);
var m = d.getMonth();
var sixMonthAfterToday = new Date(now).setMonth(now.getMonth() + 6);
var dtUserSixMonthAfter = d.setMonth(d.getMonth() + 6);
if(dtUserSixMonthAfter > sixMonthAfterToday) {
alert("The date entered must not be greater than 6 months");
}
if(true) {
alert("The date entered cannot be in the past");
}
}
</script>
</body>
how can I check if the date cannot be in the past and not six month greater it ?