Posted By

mcarneiro on 09/04/09


Tagged

validation


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

fbiz
nalmeida


date validation


 / Published in: JavaScript
 

  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  

You need to login to post a comment.