<!DOCTYPE html>
<html lang="ko-KR">
<head>
<meta charset="utf-8" />
<title>title</title>
<style type="text/css">
button.ui-datepicker-current,
button.ui-datepicker-trigger,
table.ui-datepicker-calendar { display:none; }
</style>
</head>
<body>
<div id="document_wrap">
<div id="content_box">
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
<script>
$(document).ready(function () {
$.datepicker.monthpicker = {
closeText: '닫기',
nextText : '다음 달',
prevText : '이전 달',
currentText : "오늘",
changeMonth : true,
changeYear : true,
monthNames : ['1월','2월','3월','4월','5월','6월','7월','8월','9월','10월','11월','12월'],
monthNamesShort : ['1월','2월','3월','4월','5월','6월','7월','8월','9월','10월','11월','12월'],
dayNames : [ "일요일", "월요일", "화요일", "수요일", "목요일", "금요일", "토요일" ],
dayNamesShort : ['일', '월', '화', '수', '목', '금', '토'],
dayNamesMin : ['일', '월', '화', '수', '목', '금', '토'],
weekHeader : "주",
firstDay : 0,
isRTL : false,
showMonthAfterYear : true,
yearSuffix : "년",
showOn: 'both',
// buttonText: "달력",
showButtonPanel: true,
dateFormat: 'yy-mm',
yearRange: "-10:+0",
};
$.datepicker.setDefaults($.datepicker.monthpicker);
var datepicker_default = {
showOn: 'both',
buttonText: "달력",
currentText: "이번달",
changeMonth: true,
changeYear: true,
showButtonPanel: true,
yearRange: 'c-99:c+99',
showOtherMonths: true,
selectOtherMonths: true
}
datepicker_default.closeText = "선택";
datepicker_default.dateFormat = "yy-mm";
datepicker_default.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("option", "defaultDate", new Date(year, month, 1));
$(this).datepicker('setDate', new Date(year, month, 1));
}
datepicker_default.beforeShow = function () {
var selectDate = $("#sdate").val().split("-");
var year = Number(selectDate[0]);
var month = Number(selectDate[1]) - 1;
$(this).datepicker("option", "defaultDate", new Date(year, month, 1));
}
$(".month_picker").datepicker(datepicker_default);
});
</script>
<form name="frmEX">
년-월 :
<input type="text" name="sdate" id="sdate" size="7" maxlength="7" value="2018-10" />
<br />
년, 월만 선택 할수 있도록 변경하였습니다.
</form>
</div>
</div>
</body>
</html>