Return to Snippet

Revision: 17427
at September 4, 2009 10:34 by mcarneiro


Updated Code
(function(scope){
	scope = scope || window;
	var bissexto = function(year){
		return year%4==0 && year%100!=0 || year%400==0;
	};
	var dayByMonth = [null,31,28,31,30,31,30,31,31,30,31,30,31];
	scope.validDate = function(year, month, day){
		return bissexto(year) && month==2 ? day<=29 : day <= dayByMonth[month];
	}
})(window);

Revision: 17426
at September 4, 2009 10:32 by mcarneiro


Initial Code
(function(scope){
	scope = scope || window;
	var bissexto = function(ano){
		return ano%4==0 && ano%100!=0 || ano%400==0;
	};
	var diaMensal = [0,31,28,31,30,31,30,31,31,30,31,30,31];
	scope.validDate = function(day, month, year){
		return bissexto(year) && month==2 ? day<=29 : day <= diaMensal[month];
	}
})(window);

Initial URL

                                

Initial Description

                                

Initial Title
date validation

Initial Tags
validation

Initial Language
JavaScript