date validation


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. (function(scope){
  2. scope = scope || window;
  3. var bissexto = function(year){
  4. return year%4==0 && year%100!=0 || year%400==0;
  5. };
  6. var dayByMonth = [null,31,28,31,30,31,30,31,31,30,31,30,31];
  7. scope.validDate = function(year, month, day){
  8. return bissexto(year) && month==2 ? day<=29 : day <= dayByMonth[month];
  9. }
  10. })(window);

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.