0
$("#SAProstarteDate, #SAProendDate").datepicker({
changeMonth: true,
changeYear: true,
showButtonPanel: true,
dateFormat: 'MMyy',
onClose: function(dateText, inst) {
var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
$(this).datepicker('setDate', new Date(year, month, 1));
},
beforeShow : function(input, inst) {
if ((datestr = $(this).val()).length > 0) {
year = datestr.substring(datestr.length-4, datestr.length);
month = jQuery.inArray(datestr.substring(0, datestr.length-5), $(this).datepicker('option', 'monthNames'));
$(this).datepicker('option', 'defaultDate', new Date(year, month, 1));
$(this).datepicker('setDate', new Date(year, month, 1));
}
var other = this.id == "SAProstarteDate" ? "#SAProendDate" : "#SAProstarteDate";
var option = this.id == "SAProstarteDate" ? "maxDate" : "minDate";
if ((selectedDate = $(other).val()).length > 0) {
year = selectedDate.substring(selectedDate.length-4, selectedDate.length);
month = jQuery.inArray(selectedDate.substring(0, selectedDate.length-5), $(this).datepicker('option', 'monthNames'));
$(this).datepicker("option", option, new Date(year, month, 1));
}
}
});
----------
<div class="col-lg-4 col-md-4">
<div class="form-horizontal">
<div class="form-group">
<label for="SAProstarteDate" class="col-sm-4 control-label">Start Date</label>
<div class="col-sm-8">
<input type="text" class="form-control" validate="true" match="^(19|20)\d\d[- ](0[1-9]|1[012])[-](0[1-9]|[12][0-9]|3[01])$" error="* Please enter a valid Dispatch Date" id="SAProstarteDate" name="SAProstarteDate" placeholder="YYYY-MM" readonly="readonly">
<div class="text-danger error" role="alert">This is the error msg!</div>
</div>
</div>
</div>
</div>
<div class="col-lg-4 col-md-4">
<div class="form-horizontal">
<div class="form-group">
<label for="SAProendDate" class="col-sm-4 control-label">End Date</label>
<div class="col-sm-8">
<input type="text" class="form-control" validate="true" match="^(19|20)\d\d[- ](0[1-9]|1[012])[-](0[1-9]|[12][0-9]|3[01])$" error="* Please enter a valid Dispatch Date" id="SAProendDate" name="SAProendDate" placeholder="YYYY-MM" readonly="readonly">
<div class="text-danger error" role="alert">This is the error msg!</div>
</div>
</div>
</div>
</div>
如何將此日期範圍(月,年)日期選擇器轉換爲顯示月份和數據格式 - 月份和日期應該是數字格式(mmyy)Plz幫助將其轉換爲該格式如何轉換此日期範圍(月,年)日期選擇器以顯示數字格式的月份輸出
歡迎來到Stack Overflow!當你問你的問題時,文本區域右側有一個大的橙色**如何格式化**框,其中包含有用的信息。還有一個格式化輔助工具的整個工具欄。和一個** [?] **按鈕提供格式幫助。 *和*位於文本區域和發佈問題按鈕之間的預覽區域(以便您必須掃描過去以找到該按鈕),以顯示發佈後帖子的樣子。明確你的帖子,並證明你花時間這樣做,提高你獲得良好答案的機會。 –
另外,請參加[旅遊],環顧四周,並閱讀[幫助],特別是[*我如何提出一個好問題?](/ help/how-to-ask)問題是太廣泛了。你有什麼嘗試?你堅持什麼部分? –