jQuery UI Picking a start and end date within range based on start date

后端 未结 3 1379
深忆病人
深忆病人 2021-02-13 13:39

I\'m building a date picker in jQuery ui. What I\'m trying to do is set a range, so when they pick the first date the second date appears and gives a 30 day window. I tried this

3条回答
  •  忘了有多久
    2021-02-13 14:19

    $("#start_date").datepicker().on('changeDate', function(selected){
            startDate = new Date(selected.date.valueOf());
            $('#end_date').datepicker('setStartDate', startDate);
        });  
    
        $("#end_date").datepicker().on('changeDate', function(selected){
            startDate = new Date(selected.date.valueOf());
            $('#start_date').datepicker('setEndDate', startDate);
        });
    

提交回复
热议问题