JQuery - end date less than start date

后端 未结 6 1907
一生所求
一生所求 2020-12-16 08:12

I\'m trying to fix this problem I\'m having. I have to input tags, one is for Training beginning date and other is for training ending date. What i am trying to do is create

6条回答
  •  臣服心动
    2020-12-16 08:30

    Here you have the same question with Jquery UI Datepicker jQuery UI Picking a start and end date within range based on start date And a working example:

    html

    
    
    

    js

    $(document).ready(function () {
    
        $("#dt1").datepicker({
            dateFormat: "dd-M-yy",
            minDate: 0,
            onSelect: function (date) {
                var dt2 = $('#dt2');
                var startDate = $(this).datepicker('getDate');
                var minDate = $(this).datepicker('getDate');
                dt2.datepicker('setDate', minDate);
                startDate.setDate(startDate.getDate() + 30);
                //sets dt2 maxDate to the last day of 30 days window
                dt2.datepicker('option', 'maxDate', startDate);
                dt2.datepicker('option', 'minDate', minDate);
                $(this).datepicker('option', 'minDate', minDate);
            }
        });
        $('#dt2').datepicker({
            dateFormat: "dd-M-yy"
        });
    });
    

    http://jsfiddle.net/PPSh3/7/

    Hope that help

提交回复
热议问题