user5742277
user5742277

Reputation: 23

display whole year using datepicker in jquery

I m using jquery to display the whole year calender using datepicker jquery. But in my code it displays only till todays date. It doesnt display all months date in my code. Here is the code

 $("#XIStudentDOB").datepicker({
                onSelect: function (value, ui) {

                    var toDate = new Date(2016, 05, 01);
                    var fromDate = new Date(value);
                    var days = (toDate - fromDate) / 1000 / 60 / 60 / 24;
                    var y = 365;
                    var y2 = 31;
                    var remainder = days % y;
                    var casio = remainder % y2;
                    year = (days - remainder) / y;
                    month = (remainder - casio) / y2;

                    var displayMonth = fromDate.getMonth() + 1;

                    var DateString = fromDate.getDate() + "/" + displayMonth + '/' +  fromDate.getFullYear();
                    $("#XIStudentDOB").val(DateString);


                    $("#age").val(year);
                    $("#months").val(month+1);

                },
                dateFormat: 'yy,mm,dd',
                defaultDate: '2000,01,01',
                maxDate: '+0d',
                yearRange: '2001:2016',
                changeMonth: true,
                changeYear: true
            });

Whats wrong in the code. I want to display all the months in year.The above code also calculates age of the student

Upvotes: 0

Views: 78

Answers (2)

Jasbeer Singh
Jasbeer Singh

Reputation: 37

you can use something like this

   $("#datepicker").datepicker( {
   format: "MMMM YYYY"
    });

Upvotes: 0

Rav
Rav

Reputation: 300

maxDate is set to current date, please change this to following

var current_year = (new Date).getFullYear();
maxDate: new Date(current_year, 11, 31)

This will set the maxDate to current year max date

Upvotes: 1

Related Questions