Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery datepicker issue with format

When I type in the input field the string 01/01/24 it returns the date 01/01/2024 but if I type 01/01/25 it returns the date 01/01/1925.

Is it possible to prevent this event and always return a date after the year 2000?

The user doesn't want me to change the dateFormat by using dd/mm/yy, so I'm stuck with the format dd/mm/y.

Here is the js I use for creating the datepicker:

$('.hasDatepicker').datepicker({
    showOn: "button",
    buttonImage: imagePrefix + "/img/calendar_1.png",
    buttonImageOnly: true,
    dateFormat: "dd/mm/y",
    yearRange: "2000:2099",
    onSelect: function(e, d) {
        $(this).trigger("change");
    }
});
like image 907
Mupmup Avatar asked Aug 05 '14 14:08

Mupmup


1 Answers

It's because the option shortYearCutoff:

The cutoff year for determining the century for a date (used in conjunction with dateFormat 'y'). Any dates entered with a year value less than or equal to the cutoff year are considered to be in the current century, while those greater than it are deemed to be in the previous century.

the default value is +10, you can enlarge it to a major value like +50.

Demo: http://jsfiddle.net/IrvinDominin/5Db32/

like image 160
Irvin Dominin Avatar answered Sep 28 '22 18:09

Irvin Dominin