Przemek
Przemek

Reputation: 6700

Configuring jQuery UI datepicker for name day selection (do not show the year in the datepicker)

One of my project's requirements is to keep users' name days. For those who don't know what a name day is - a quote from Wikipedia: "A name day is a tradition in many countries in Europe and Latin America that consists of celebrating the day of the year associated with one's given name."

Basically, the idea is to store only the day and month, the year is irrelevant since a person's name day occurs every year. In the database I'm using the DATE type, without displaying the year part in any views.

I'm using jQuery UI datepicker to select dates in my application. Is there a way to configure the datepicker to somehow ommit year selection? For example - set it to current year and don't display the year at all?

I don't want to modify the datepicker's code and I also like the rest of my datepickers to work and look properly.

Upvotes: 2

Views: 946

Answers (1)

Nicola Peluchetti
Nicola Peluchetti

Reputation: 76880

You could try setting

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

and then hide the year with CSS:

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

here is a fiddle: http://jsfiddle.net/uLtS4/

Upvotes: 2

Related Questions