2016-03-15 69 views
0

我想顯示像(2015年3月2日 - 2016年3月12日)多個日期選取範圍格式使用一個插件http://multidatespickr.sourceforge.net/,我嘗試下面的代碼如何在多日期選擇器插件中顯示月份名稱?

$(function() { 
    $(".datepicker").multiDatesPicker({ 
     minDate: 0, 
     showButtonPanel: true, 
     changeMonth: true, 
     changeYear: true, 
     onSelect: function(dateText, inst) { 
        inst.settings.defaultDate = dateText; 
        } 
    }); 
}); 

,但它不能正常工作,有人能幫助我嗎?

+0

你在哪裏要顯示一個月? – TheVillageIdiot

+0

像輸入框格式一樣(2015年3月2日 - 2016年3月12日) –

回答

0

您可能不需要onSelect處理程序。這是很容易可能的下列設置做:

dateFormat: "M d, yy", 
separator:' - ' 

$(function() { 
 
     $("#dp").multiDatesPicker({ 
 
     dateFormat: 'M d, yy',separator:' - ' 
 
     }); 
 
    });
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css" /> 
 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script> 
 
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script> 
 
<script src="http://multidatespickr.sourceforge.net/jquery-ui.multidatespicker.js"></script> 
 
<link rel="stylesheet" href="http://multidatespickr.sourceforge.net/css/pepper-ginder-custom.css" /> 
 

 
<input id="dp" type="text" />

+0

我得到了30%的結果,這裏當我選擇更多然後兩個日期在輸入框中可見多於兩個日期,但我需要日期 - 2015年3月2日 - 2016年3月12日 –

+0

日期選擇器範圍表單喜歡2015年3月2日 - 2016年3月12日需要輸入框 –

+0

好吧,它會使50%不是30,希望現在是100%。 – TheVillageIdiot

相關問題