block months from a given date

-1

I have a doubt I have these two fields which are date fur: date last rule and fpp: probable date of birth now what I want to achieve is that when I enter a date in fur I block 7 months onwards in fpp from the date that you enter in fpp. If someone has an example, I would appreciate it.

    
asked by yoclens 11.04.2017 в 18:54
source

1 answer

0

here the solution

<script>

function add_months(datestr, months) {
    var new_d = new Date(datestr);
    new_d.setMonth(new_d.getMonth() + months);
    return new_d;
}
$(document).ready(function() {

    $('#fur').pickadate({
        selectMonths: true,
        selectYears: 10,
        format: 'yyyy-mm-dd',
        onClose: function() {
            var date_add_m = add_months($('#fur').val(), 7);
            $('#fpp').pickadate({
                selectMonths: true,
                selectYears: 10,
                format: 'yyyy-mm-dd',
                disable: [{
                    from: new Date($('#fur').val()),
                    to: date_add_m
                }]
            })
        }
    });
});
</script>

the input

<input type="text" name="fur"  id="fur"/>

<input type="text" name="fpp"  id="fpp">
    
answered by 11.04.2017 / 20:38
source