Never been to CodeSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

check an age to see if they meet a minimum requirement (See related posts)

// description of your code here

		
		formMonth = $("#edit-profile-birth-date-month").val();
		formDay = $("#edit-profile-birth-date-day").val();
		formYear = $("#edit-profile-birth-date-year").val();	
		currentMonth = 10;
		currentDay = 24;
		currentYear = 2008;
	
		requiredAge = 13;
		oldEnough = false;
		nonSafeYear = currentYear - requiredAge;
	
		//do the age validation logic here
		if(formYear <  nonSafeYear){
			oldEnough = true;
		
		}else if(formYear == nonSafeYear){
		
			// check month
			if(formMonth > currentMonth){
				oldEnough = true;
	
			}else if(formMonth == currentMonth){
	
				//check day
				if(formDay > currentDay){
					oldEnough = true;
				}
			
			}
			
		}

You need to create an account or log in to post comments to this site.