Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: Date Validation


Message #1 by aoadeyemo@h... on Tue, 10 Apr 2001 09:46:45
function testDate(nDay, nMonth, nYear)
{
 var dtEvent = new Date();

 dtEvent.setFullYear(nYear, nMonth, nDay) ;

  if(dtEvent.getYear() == nYear 
     && dtEvent.getMonth() == nMonth 
     && dtEvent.getDate() == nDay)
  {
     return true;
  }
  else
  {
     return false ;
  }
}

take care that testDate(29,01,1999) returns false

indeed you have to understant it like 1 month AND 29 days so
this the date 29th February 1999 which doesn't exist...

you can change the format as you like by reversing the parameters..or else


  Return to Index