In comp.lang.javascript message <c59e890c-8b5a-4839-b48b-a3f63084d97c@r3
4g2000vba.googlegroups.com>, Thu, 6 Aug 2009 11:25:39, okey
It gives a valid Date Object, with value NaN, "A Date object contains a
number indicating a particular instant in time to within a millisecond.
The number may also be NaN, indicating that the Date object does not
represent a specific instant of time."
A Date Object is invariably valid. Any attempt to create or adjust a
Date Object will lead to one containing either the value NaN or a value
in the range -864e13 to +864e13 inclusive (except that in Safari higher
numbers are, although sinful, possible [1]).
If you had had the sagacity to read the newsgroup FAQ, linked daily from
obvious articles here, you might have come across its Section 4.2; or a
Web search for "JavaScript date string validate" would have shown over
two million candidates, at least one of which should be good for numeric
dates.
Your proposed test will necessarily fail to reject, in at some browsers,
bad month names. One accepts "Bananas" as meaning the current month;
two others accept "Octopus" as meaning October. See
<URL:
http://www.merlyn.demon.co.uk/js-datex.htm> for that, and
<URL:
http://www.merlyn.demon.co.uk/js-date4.htm> for validation.
Since some common date formats, such as 07/08/09, have multiple
interpretations, one needs to stipulate the format.
what about?...
if (isNaN(oD.getDate() + oD.getMonth() + oD.getYear())) { ...
(if any getXXXX() is NaN, then all are not NaN?)
Just reaching..
t
[1] ISTM that Safari uses 32-bit signed years internally.