-1
I need a help, I have a form of reservation of rooms, have as I increase the number of days of a date that the user selected, received by the value of the html form?
Like something like that.
function myFunction() {
var datainicio = $("#dtini").val();
let d = new Date(); // data atual
d.setDate(d.getDate() + 2);
var a = d.getFullYear()+"-"+d.getMonth()+"-"+d.getDate();
alert(a);
$('#dtfim').attr('min',a);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<input id="dtini" type="date" min="2021-02-10" onchange="myFunction()">
<input id="dtfim" type="date">
But in this case, it is only printed at the current date + 3, I need to add with the date selected by the user himself. Thanks in advance!
let d = new Date(); // data atual
, why did you do this instead of using the variabledatainicio
?– Woss
It was only an example, but I’ve tested it with the variable itself, but it didn’t work.
– Marlon Dietrich