jQuery datepicker to show month and year only

In reporting specially, datepicker with month and year only are a better way to provide information to form for submission without need of the day.
In my case, I modified one picker $( “#month” ).datepicker to fill both month and year input field

$( "#month" ).datepicker({
		buttonImageOnly: true,
		dateFormat: "MM yy",
		changeMonth: true,
		changeYear: true,
		showButtonPanel: true,
		numberOfMonths: 1,
		//setDate: checkindate,
		onClose: function(dateText, inst) {
            var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
            var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
            $("#month").val($.datepicker.formatDate('mm', new Date("", month, 1)));
            $( "#year" ).val($.datepicker.formatDate('yy', new Date(year, "", 1)));
        },

	});
	Month: <input type="text" id="month" name="month"></input>
	<br></br>
	Year: <input type="text" id="year" name="year"></input>

By Keenlio, February 21, 2014

What do you think?

Leave a Reply

Your email address will not be published. Required fields are marked *


1 + = five

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>