HighDots Forums  

Re: Date Validation

Javascript JavaScript language (comp.lang.javascript)


Discuss Re: Date Validation in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
pcx99
 
Posts: n/a

Default Re: Date Validation - 05-12-2004 , 01:41 AM






There are a lot of good answers on this thread but personally I think
javascript itself is a better date validator.

function isDate(sDate) {
var scratch=new Date(sDate);
if (scratch.toString()=="NaN" || scratch.toString()=="Invalid Date") {
alert("Not a Date");
return false;
} else {
return true;
}

Javascript's date parser is actually very robust and powerful and able
to hande 1/20/2004 as well as January 20 2004. IE returns NaN (not a
number) when it can't figure out a date, Mozilla (gekko engine) returns
Invalid Date.

--
-------------
http://www.hunlock.com -- DHTML for the rest of us.

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.