Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery datepicker - only day and month

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.

like image 586
tanon Avatar asked Jul 23 '11 07:07

tanon


3 Answers

You could do:

$('#date').datepicker( {
        changeMonth: true,
        changeYear: true,
        showButtonPanel: true,
        dateFormat: 'dd MM'
    });

fiddle http://jsfiddle.net/u8GnD/1/

like image 165
Nicola Peluchetti Avatar answered Nov 09 '22 19:11

Nicola Peluchetti


set the css to hide the year and the dateFormat as K6t said

.ui-datepicker-year{
    display:none;
}
like image 29
Emil Condrea Avatar answered Nov 09 '22 19:11

Emil Condrea


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.

like image 7
Rafi Avatar answered Nov 09 '22 18:11

Rafi