- Code: Select all
function isValidDate(iDay, iMonth, iYear)
{
if (iDay == 31 && (iMonth == 4 || iMonth == 6 || iMonth == 9 || iMonth == 11))
return false;
else if (iMonth == 2)
{
iMaxDays = ((iYear%4 == 0 && (iYear% 100 != 0 || iYear%400 == 0)) ? 29 : 28);
if (iDay > iMaxDays)
return false;
}
return true;
}
Usage
You can call the date validation function by passing the day, month and year as individual parameters and this function will returns true or false against that date.