Feedback on: irt.org FAQ Knowledge Base Q1
Worth:
Worth reading
Length:
Just right
Technical:
Just right
Comments:
I don't think this technique actually works - at any rate, not on my PC (using IE5 under NT4) - it does not seem to observe the correct number of days in each month. For example, 31/4/1957 is considered valid (whereas 31/4 does cause an error). Similarly, 29/2/nnnn works OK for any year, not just leap years.
(For testing, I simplified the isDate function as follows, but I don't think this will have made any difference.)
function isDate (day,month,year) {
var test = new Date(year,month,day);
if (day == 0) return false;
if (month == 0) return false;
if (year == 0) return false;
if ((year == test.getFullYear()) &&
(month == test.getMonth()) &&
(day == test.getDate()))
return true
else
return false
}
Comments:
Sorry, cancel previous feedback - I forgot about the (month-1) trick! The following simplified version works fine:
function isDate (day,month,year) {
var test = new Date(year,month-1,day);
if (day == 0) return false;
if (month == 0) return false;
if (year == 0) return false;
if ((year == test.getFullYear()) &&
(month == test.getMonth() + 1) &&
(day == test.getDate()))
return true
else
return false
}
Worth:
Not worth reading
Comments:
the code is unreadable - is it in hieroglyphics?
Worth:
Worth reading
Length:
Just right
Technical:
Just right
Comments:
The only problem: it doesn't work in Netscape 4.75 because it always returns a 'false'-value...
Worth:
Worth reading
Comments:
This page code helped me much, but
I found a bug.
It should be like this:
var test = new Date(year,month -1,day);
if ( (y2k(test.getYear()) == year) &&
(month == (test.getMonth() +1)) &&
JavaScript treates months from 0 - 11.
The original code seems to be fine, but does'nt work.
ex) month = 3, day = 31.