JQuery Restrict the difference between two datepickers

后端 未结 4 1677
小鲜肉
小鲜肉 2021-01-24 09:04

I have 2 datepickers

  $(function() {
    $(\'#DateFrom\').datepicker({ onSelect: showUser, minDate: -90, maxDate: \"+1D\" });
  });

  $(function() {
    $(\'#         


        
4条回答
  •  情歌与酒
    2021-01-24 09:33

    Something like this

    $(function () {
        $('#DateFrom').datepicker({
            onSelect: function() {
                var date = $('#DateFrom').datepicker('getDate');
                date.setTime(date.getTime() + (1000*60*60*24*6));
                $('#DateTo').datepicker('option', 'maxDate', date);
                $('#DateTo').datepicker('option', 'minDate', $('#DateFrom').datepicker('getDate'));
                showUser();
            },
            minDate: -90, 
            maxDate: "+1D"
        });
    
        $('#DateTo').datepicker({
            onSelect: showUser,
            minDate: -90, 
            maxDate: "+1D"
        });
    });
    

    FIDDLE

提交回复
热议问题