0

In my form, I have three select elements, which are Month, Day, and Year. What I'm achieving is, if the user selects a month, the days must match according to what month the user has selected.

For example, January(1-31), May(1-30), February(1-28).

Arulkumar
  • 12,966
  • 14
  • 47
  • 68
darkAnonymous
  • 53
  • 1
  • 1
  • 5

1 Answers1

0
function GetDays(year, month) {
    var isLeapYear = ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0);

    return [31, (isLeapYear ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month];
}

Call GetDays function on change event of month selection control

Bhavik Jani
  • 180
  • 7