Dec 20, 2021
0
Level 1
Javascript input date conditional choice
this maxdate should not enter a value before the date in the previous field.
<div class="col-sm-2">
<div class="form-sh">
<input id="mindate" type="date" min="<?php echo date("Y-m-d"); ?>" name="mindate">
</div>
</div>
<div class="col-sm-2">
<div class="form-sh">
<input onchange="updateInput(this.value)" id="maxdate" type="date" min="<?php echo date("Y-m-d"); ?>" name="maxdate">
</div>
</div>
Javascript
$(document).ready( function() {
$('#mindate').val(new Date().toDateInputValue());
$('#maxdate').val(new Date().toDateInputValue());
});
function updateInput(ish){
var mindate = document.getElementById("mindate");
document.getElementById("maxdate").value = mindate;
$('input[name="maxdate"]').val(mindate);
}
Please or to participate in this conversation.