jquery datepicker多个最小最大日期

时间:2015-08-29 17:31:21

标签: jquery datepicker range

我在使用jQuery datepicker时遇到了一些麻烦。我需要多个范围来选择日期。例如,用户应该能够选择(d-m-y)1/8/2015和5/8/2015之间的范围。但也介于:2015年8月16日至2015年8月20日之间(在同一日历中)。与这些范围不匹配的日期应为非活动状态。我最终尝试使用以下代码,但没有成功:

    $(function() {    
    var ds = array('1-8-2015', '16-8-2015'),
        de = array('5-8-2015', '20-8-2015');

    $('#datepicker').datepicker({
        beforeShow: function() {
            return {
                dateFormat: 'd-m-yy',
                minDate: ds,                
                maxDate: de,

            }
        }
    });
});

JSFiddle示例: JSfiddle

有什么想法吗? 此致,西蒙

1 个答案:

答案 0 :(得分:2)

是的..你可以这样做..你可以使用Sub Make_AVERAGEIFS() Dim FindString As Date Dim Sumact As Range Dim Analyst As Double Dim shname As String Dim d As Integer, m As Integer, y As Integer Do Until WorksheetExists(shname) shname = InputBox("Enter sheet name") If Not WorksheetExists(shname) Then MsgBox shname & " doesn't exist!", vbExclamation Loop With worksSheets(shname) .Activate FindString = InputBox("Enter a Search value") If Trim(FindString) <> "" Then With .Range("A:A") Set Sumact = .Find(What:=FindString, _ After:=.Cells(.Cells.Count), _ LookIn:=xlValues, _ LookAt:=xlWhole, _ SearchOrder:=xlByRows, _ SearchDirection:=xlNext, _ MatchCase:=False) If Not Sumact Is Nothing Then Application.Goto Sumact, True Else MsgBox "Nothing found" End If End With End If If IsDate(Sumact) Then d = Day(Sumact): m = Month(Sumact): y = Year(Sumact) Analyst = Application.AverageIfs(.Columns(2), _ .Columns(1), "<" & DateSerial(y, m, d), _ .Columns(1), ">" & DateSerial(y, m - 6, d)) End If End With Selection.Copy End Sub 的{​​{1}}选项,如下所示:

beforeShowDay

<强> Source