Created
May 5, 2016 02:58
-
-
Save karki-dennis/32cbb320a0618e007a9f0e63e7ec796d to your computer and use it in GitHub Desktop.
Ui date picker month and year only
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<input type="text" class="only-month-year"> | |
<script type="text/javascript"> | |
jQuery(function ($) { | |
jQuery(document).ready(function ($) { | |
$(".only-month-year .datepicker").datepicker({ | |
dateFormat: 'MM yy', | |
changeMonth: true, | |
changeYear: true, | |
showButtonPanel: true, | |
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).val($.datepicker.formatDate('MM yy', new Date(year, month, 1))); | |
} | |
}); | |
$(".only-month-year .datepicker").focus(function () { | |
$(".ui-datepicker-calendar").hide(); | |
$("#ui-datepicker-div").position({ | |
my: "center top", | |
at: "center bottom", | |
of: $(this) | |
}); | |
}); | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment