Skip to content

Instantly share code, notes, and snippets.

@jcsrb
Created July 22, 2014 07:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jcsrb/21107da479285d38d1a5 to your computer and use it in GitHub Desktop.
Save jcsrb/21107da479285d38d1a5 to your computer and use it in GitHub Desktop.
var validateAgeOlderOrExactly = function(date_string, age_limit_year, age_limit_month) {
var ageLimitDate, birthDate, today;
if (age_limit_month == null) {
age_limit_month = 0;
}
today = new Date();
birthDate = new Date(date_string);
ageLimitDate = new Date(today.getFullYear() - age_limit_year, today.getMonth() - age_limit_month, today.getDate());
return birthDate <= ageLimitDate;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment