I am trying to calculate date from difference and I cant make it work.
I use this code:
$('#TextBox1, #TextBox2').on('input', function() {
getdate();
});
function getdate() {
var month = $('#TextBox1').val();
var num_month = $('#TextBox2').val();
var date = new Date(month);
var newdate = new Date(date);
newdate.setDate(newdate.getDate() + 1);
var dd = newdate.getDate();
var mm = newdate.getMonth() + num_month;
var yyyy = newdate.getFullYear();
var someFormattedDate = mm + '/' + dd + '/' + yyyy;
$('#TextBox3').val(someFormattedDate);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p>Date From :
<input type="date" id="TextBox1" />
</p>
<p>Difference :
<input type="number" id="TextBox2" />
</p>
<p>Date To :
<input type="date" id="TextBox3" />
</p>
First input field I set the date, and then the second field I want to enter a number and add that number to the month. and then the third input field will show the calculated output.
for example, I put 11/29/2018 on the first input field and then I type 3 on the second input field. third input field must show 1/29/2019. because 11 is November plus 3 months will be equal to January.