Skip to content

Instantly share code, notes, and snippets.

@VMBindraban
Created February 17, 2016 07:59
Show Gist options
  • Save VMBindraban/7103193adc69d81cc4d7 to your computer and use it in GitHub Desktop.
Save VMBindraban/7103193adc69d81cc4d7 to your computer and use it in GitHub Desktop.
function isValidDate(date) {
var day = date.substr(0, 2),
month = date.substr(3, 2),
year = date.substr(6, 4);
return !(
(month < 1 || month > 12) ||
(day < 1 || day > 31) ||
((month == 4 || month == 6 || month == 9 || month == 11) && day > 30) ||
(month == 2 && day > 29) ||
(month == 2 && day > 28 && !(year % 4 == 0 && (year % 100 == 0 || year % 400 == 0)))
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment