问题
I want the user to specify their birthday or anniversary date (without year) in a form. For this, I want to use jquery datepicker but it should not show any year option at all. How to do it?
I tried modifying the code in this so question by making changeDay: true
and changeYear: false
but could not get it to work.
回答1:
set the css to hide the year and the dateFormat as K6t said
.ui-datepicker-year{
display:none;
}
回答2:
You could do:
$('#date').datepicker( {
changeMonth: true,
changeYear: true,
showButtonPanel: true,
dateFormat: 'dd MM'
});
fiddle http://jsfiddle.net/u8GnD/1/
回答3:
You can hide year from a datepicker like this :
$(".daypicker").datepicker( {
changeYear: false,
dateFormat: 'MM-dd',
}).focus(function () {
$(".ui-datepicker-year").hide();
});
It wont affect to other datepickers in same page.
回答4:
$("#datepicker").datepicker( {
format: "dd-MM",
viewMode: "months",
maxViewMode: "months"
});
this will surely hide year from datepicker view, will show only month and days panel
回答5:
$( function() {
var date = $('#datepicker').datepicker({
dateFormat: 'yy-mm-dd',
changeMonth: true,
changeYear: false}).val();
});
回答6:
change dateFormat as
dateFormat: 'dd MM',
in datePicker.js file
来源:https://stackoverflow.com/questions/6799092/jquery-datepicker-only-day-and-month