2
How can I convert my jQuery datepicker to accept only months and years ?
2
How can I convert my jQuery datepicker to accept only months and years ?
3
For this jQuery datepicker you can make a hack that works the following way:
Add None to the CSS class of the days as below:
.ui-datepicker-calendar {
display: none;
}
Soon after you set up your datepicker that way:
$('.date-picker').datepicker({
changeMonth: true,
changeYear: true,
showButtonPanel: true,
dateFormat: 'MM yy',
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));
}
});
Follows the jsfiddle.
Good idea, the only problem I see is if there are other datepickers on the same page. But joining a id
or a specific class is solved. +1
Well posted @Sergio, I’ll put this remark :))
Very good was exactly what I needed. Thank you
2
I know it escapes a little of your question... but I use following plugin:
https://bootstrap-datepicker.readthedocs.org/en/latest/options.html#maxviewmode
See if that’s what you need. I have nothing to complain about him... other than he’s very elegant!
I did some tests here with this datepicker, besides it being very beautiful works beautifully rs .. + 1 :D
-1
<script>
$(".datepicker" ).datepicker({
startView: 1,
minViewMode: 1,
maxViewMode: 3,
format: "mm-yyyy",
changeMonth: true,
changeYear: true
});
</script>
Browser other questions tagged javascript jquery datepicker
You are not signed in. Login or sign up in order to post.
you are using this datepicker https://jqueryui.com/datepicker/ ?
– Brunno
Example using jQueryUI datepicker: http://jsfiddle.net/DBpJe/5106/
– OnoSendai