I have a form where I want to validate 2 datetime-local a start-date and an end-date. What I want is to not let the user select a start date older than 48 hours (browser time) and the end date to not be set in past. This is my code till now:
<form>
<tr>
<td>
<input type="datetime-local" name="start_timestamp" id="start_timestamp" required>
</td>
<td>
<input type="datetime-local" name="end_timestamp" id="end_timestamp" required>
</td>
</tr>
</form>
And the js so far (PS: I am not very good at js)
var start_date = document.getElementById("start_timestamp").value;
var end_date = document.getElementById("end_timestamp").value;
var now = new Date().toDateString();
if (end_date < start_date) {
return 1;
}
else {
return 0;
}
if (start_date < now-2) {
return 1;
}
else {
return 0;
}