skip to main | skip to sidebar
Showing posts with label javascript. Show all posts
Showing posts with label javascript. Show all posts

Sunday, February 04, 2007

checkDate in Javascript

I know there are lots of implementations of date validation in Javascript out there, but I've just started learning Javascript and wanted to share this implementation with you, so here are my first two little javascript cents:

function checkDate(month, day, year)
{
var monthLength =
new Array(31,28,31,30,31,30,31,31,30,31,30,31);

if (!day || !month || !year)
return false;

// check for bisestile year
if (year/4 == parseInt(year/4))
monthLength[1] = 29;

if (month < 1 || month > 12)
return false;

if (day > monthLength[month-1])
return false;

return true;
}

Pubblicato da betto a 6:16 PM 2 commenti

Etichette:

Subscribe to: Comments (Atom)
 

AltStyle によって変換されたページ (->オリジナル) /