jquery ui datepicker - how to set two min/max date restrictions in one datepicker?

后端 未结 2 2000
遥遥无期
遥遥无期 2021-01-28 16:43

I am using the jquery ui datepicker with select date range. I know that by default it already set if the from picks a date then the to date can not pick any date before the fro

2条回答
  •  生来不讨喜
    2021-01-28 17:16

    You can refer to this link : http://api.jqueryui.com/datepicker/#option-maxDate

    This is to Initialize the datepicker with the maxDate option specified, not to set it up afterwards:

    $( ".selector" ).datepicker({
      maxDate: "+1m +1w"
    });
    

    To modify/get the option, use this:

    Get or set the maxDate option, after initialization:

    // Getter
    var maxDate = $( ".selector" ).datepicker( "option", "maxDate" );
    
    // Setter
    $( ".selector" ).datepicker( "option", "maxDate", "+1m +1w" );
    

    "+0" is for now()

    Same for mindate!

提交回复
热议问题