I have a Fields. One is ValidFrom Date and the other is ValidTo Date.
My question is what should I do so that if ValidFrom date is entered using DateTimePicker, how should I change the ValidTo by exactly 30 days automatically?
Following is My code for DateTimePicker:
<script src="~/Scripts/jquery.datetimepicker.js"></script>
<script>
$(document).ready(function () {
$('#ValidFrom').datetimepicker({
datepicker: true,
timepicker: false,
format: 'm/d/Y',
step: 30,
minDate: new Date(),
onChangeDateTime: function (dp, $input) {
var date = new Date($input.val());
date.setMonth(date.getMonth() + 1);
$('#ValidTo').datetimepicker({
datepicker: true,
timepicker: false,
format: 'm/d/Y',
step: 30,
minDate: date,
});
},
});
});
</script>
I have to change the ValidTo date by 30 days as and when ValidFrom date is entered.