Return to Snippet

Revision: 21522
at December 15, 2009 09:48 by adambundy


Initial Code
$("#lda-form").submit(function(){
	var day = $("#day").val();
	var month = $("#month").val();
	var year = $("#year").val();
	var age = 18;
	var mydate = new Date();
	mydate.setFullYear(year, month-1, day);

	var currdate = new Date();
	currdate.setFullYear(currdate.getFullYear() - age);
	if ((currdate - mydate) < 0){
		alert("Sorry, only persons over the age of " + age + " may enter this site");
		return false;
	}
	return true;
});

Initial URL

                                

Initial Description
courtesy Jean-Baptiste Jung

Initial Title
Validate a date of birth using jQuery

Initial Tags

                                

Initial Language
jQuery