Thursday, 7 November 2019

How to check valid date in javascript?

function isDateValid(date,month,year)
{
  var ListofDays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
  if(year<1900 year="">2100) return false;
  if(month<1 month="">12) return false;
  if(month==2)
  {
    ListofDays[1]=(year % 4 == 0 && (year % 100 != 0 || year % 400 == 0))?29:28;
  }
  if(date<1 date="">ListofDays[month-1]) return false;
  return true;
}