EarthWeb
Developer.com
Site
windows 2000
visual c++
java
visual basic
javascripts
recommend it
 
Book
thinking in java
 
Interact
forum
guest book
jobs
jokes
what's new

share code
 
Resource
add resource
modify resource
new resource
 

[Internet Jobs]
-----
Java by E-mail:

Get the weekly e-mail highlights on Java!
-----

-

Validate a date


Author: Real Gagnon
Author's WebSite: http://tactika.com/realhome/realhome.html


 <HTML><HEAD>
 <SCRIPT>
 function getYear(d) { 
   return (d < 1000) ? d + 1900 : d;
   }

 function isDate (year, month, day) {
   // month argument must be in the range 1 - 12
   month = month - 1;  // javascript month range : 0- 11
   var tempDate = new Date(year,month,day);
   if ( (getYear(tempDate.getYear()) == year) &&
      (month == tempDate.getMonth()) &&
      (day == tempDate.getDate()) )
       return true;
   else
      return false
   }

  if (isDate(1997, 2, 28))
      alert("1997-02-31 is valid!");
  else
      alert("1997-02-31 is invalid!");
 </SCRIPT></HEAD><BODY>test date</BODY>
 <HTML>



Posted On: 10-Jul-1999

internet.commerce