Age Verification

|
private bool ValidateMemberUnderage(DateTime dtBirthday, int nYears)
		{
			if (DateTime.Today.Year - dtBirthday.Year > nYears)
				return true;
			else
				if (DateTime.Today.Year - dtBirthday.Year == nYears)
				{
					DateTime dtBirthdayThisYear = dtBirthday.AddYears(nYears);
					if (DateTime.Today >= dtBirthdayThisYear)
						return true;
					else
						return false;
				}
				else
					return false;
		}
if (ValidateMemberUnderage(DateTime.Parse("1981-04-04"), 12) == false)
		{
			MessageBox.Show("Too Young");
		}
		else
		{
			MessageBox.Show("Old Enough");
		}
Originally Posted on December 16, 2013
Last Updated on October 26, 2015
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.