Feb
26
2008
26
2008
Javascript for validating a date
Javascript for validating a date.
Pass month, day, year as parameters. This function will return true if the date is valid.
// Author: arunmvishnu.com
function validDate(month, day, year){
if(month =='0' || day =='0' || year=='0'){
return false;
}
switch(month){
case '1': //** jan
case '3': //** March
case '5': //** May
case '7': //** July
case '8': //** Aug
case '10': //** Nov
case '12': //** Dec
if(day >=1 && day <= 31){
return true;
} else {
return false;
}
case '4': //** APRIL
case '6' : //** JUNE
case '9' : //** SEPTEMBER
case '11' : //** NOVEMBER
if(day >=1 && day <= 30){
return true;
} else {
return false;
}
case '2' : // Feb
if(isLeapYear(year)){
if(day >=1 && day <= 29){
return true;
}
} else if(day >=1 && day <= 28){
return true;
} else {
return false;
}
default:
return false;
}
}
function isLeapYear(year){ // Checking wdr a year is leap year or not
if(year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)){
return true;
} else {
return false;
}
}
The full js file can be dodnloaded from here
Tags: java script, Programming
Related Posts
Latest Posts
- Introducing Google Drive
- Google Account Activity gives you a monthly summary of your account activity across many Google products
- Apple released iOS 5.1
- You won’t be actually able to take 41MP photos using Nokia 808 PureView
- Apple Releases Mac OS X Mountain Lion 10.8 Developer Preview
- A walk down memory lane
- What is the real meaning of Facebook “Like”?
- Wish you and your family a very Happy and Prosperous New Year 2012!
- Import Orkut’s albums to Google+
- Download 100 Paid Android Apps(Like Fruit Ninja HD, BW, Smart Office etc. )For Free
Tags
apple
c and cpp
Cheats
download
downloads
Entertainment
Film
friendship
Fun
gadgets
Games
gmail
google
greetings
india
Internet
ipad
iphone
java script
linux
love
mac
microsoft
mobile
News
office
Orkut
Personal
photos
Programming
review
Security
software
source code
technology
Tips & Tricks
video
videos
virus
web
web development
windows
windows 7
worm
yahoo
Recent Comments
- Vikesh Kumar on C++ Program for QUICK SORT
- pratikchavan on C++ Program for QUICK SORT
- suraj on C++ Program Program for Binary Search.
- saravanan on Enabling REGEDIT and Task Manager
- VP on I Got My GirlFriend

An article by