hello so i have a javascript function that takes two dates from two date inputs, compares them and returns a boolean value except it doesn't work
function checkdate() {
var datefrom = new Date();
var dateto = new Date();
datefrom = getElementById("date_from").innerHTML;
dateto = getElementById("date_to").innerHTML;
if (datefrom > dateto) {
alert("Dateto must be bigger than datefrom ");
return false;
} else return true;
}
<form onsubmit="return checkdate()" class="forms-sample" method="post"
action="addstage.php">
<div class="form-group row">
<label for="exampleInputUsername2" class="col-sm-3 col-form-label">Date
Début</label>
<div class="col-sm-9">
<input type="date" class="form-control"
id="date_from" placeholder="Debut" name="datedebut" required="required">
</div>
</div>
<div class="form-group row">
<label for="exampleInputEmail2" class="col-sm-3 col-form-label">Date
Fin</label>
<div class="col-sm-9">
<input type="date" class="form-control"
id="date_to" placeholder="Fin" name="datefin" required="required">
</div>
</div>
<div class="form-check form-check-flat form-check-primary"></div>
<button type="submit" class="btn btn-primary mr-2" value="addStage"
name="action">Add</button>
</form>
.valueproperty, not.innerHTMLto access the value of an input element."2020-06-01" > "2020-05-30"works just fine, but sure, parsing the values into proper Date objects could have some benefits.valueis defined by the spec and doesn't have to match the displayed date which most likely will be locale-specific.