[thelist] [JS] isDate function

Joshua Olson joshua at waetech.com
Tue Mar 8 15:21:56 CST 2005


> -----Original Message-----
> From: Scott Brady
> Sent: Tuesday, March 08, 2005 4:05 PM
> 
> On Tue, 8 Mar 2005 12:49:49 -0500, Joshua Olson  wrote:
> > After searching the web for isDate functions I found myself 
> unhappy with
> > most of them.  Too long, too tedious, etc.  So, I made my 
> own to parse
> > normal US formatted dates (MM/DD/YYYY).  Can anybody spot a 
> reason why the
> > following code wouldn't work?
> 
> I don't see why that wouldn't work, but is there a reason you can't
> just do this:
> 
> function isDate(str)
> {
>      var myDate = new Date(str);
> 
>      return !isNaN(myDate);
> }
> 
> (I'm not sure about older browsers on that, but it should work for 
> 21st Century browsers, at least)

Scott,

I looked at something like that.  For starters, Mozilla/Firefox don't return
NaN when a date fails to initialize... and Opera returns an arbitrary date
from the year 0000.

Secondly, I was hoping to provide a moment for the implementer to e able to
rearrange the date fields if they expected a different format.  Perhaps that
isn't necessary.

<><><><><><><><><><>
Joshua Olson
Web Application Engineer
WAE Tech Inc.
http://www.waetech.com/service_areas/
706.210.0168 




More information about the thelist mailing list