bobighorus bobighorus - 1 month ago 6
jQuery Question

jquery ui datepicker day/month only, not year selection

I've searched here in SO and all around but no properly solutions founded for this issue.
With jQueryUI DatePicker I need to select a recursive date for all years, so I don't wanna show year selection, 'cause it doesn't make sense.

How can I obtain this inside the call like the following?

$('#myInput').datepicker({ dateFormat: "dd/mm" });


Note: I can't use css solution as suggested here
.ui-datepicker-year{
display:none;
}
because there are other datepickers in the same page.

Any help will be appreciated.

Thanks in advance.

Answer

HIya try this please demo : http://jsfiddle.net/rAdV6/20/ this is what you want bruv

which ever suits you man :) also see both screen shot below and please don't forget to accept and up vote if this helps :))

Edit to elaborate further this fix will allow to have multiple date pickers with or without year on top appear on the top of the calendar.

Hope this helps! cheers

jquery code

  $('.DateTextBox.NoYear').datepicker({
            beforeShow: function (input, inst) {
              inst.dpDiv.addClass('NoYearDatePicker');
            },
            onClose: function(dateText, inst){
                inst.dpDiv.removeClass('NoYearDatePicker');
            }
        });

$('#datepicker').datepicker( { changeYear: false, dateFormat: 'dd/mm',});


$('#datepicker1').datepicker( { changeYear: true, dateFormat: 'dd/mm', });

$('#datepicker2').datepicker( { changeYear: false, dateFormat: 'dd/mm', });
​

Css

 .NoYearDatePicker .ui-datepicker-year
{
 display:none;   
}

HTML

    <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/base/jquery-ui.css" type="text/css" media="all">

date (without year) <input type="text" id="datepicker" class="DateTextBox NoYear">

<br />
date 1: (With year) <input type="text" id="datepicker1" >
<br />
date 2: (Without year) <input type="text" id="datepicker2" class="DateTextBox NoYear">
​

Image below to show How it appears in my lappy OSX as well :)

enter image description here