Originally Posted by Old Pedant
Looking at your post #53, it becomes clearer and clearer that you don't really understand the code you are using, at all. You are grabbing at pieces of code you find all over the internet and just hoping you can shove them together and make them work. I call it the "mud on the wall" technique: You hope enough will stick to cover the wall.
I'll hate myself in the morning. I think the net result of this is that you will get a (barely) passing grade on this homework but when it comes time to take the exam, without our help, you will be more lost than ever.
function validateDob( )
var dateStr = document.getElementById('dob').value;
var dateAry = dateStr.split('/');
if (3 !== dateAry.length )
return false; // date is invalid
var m = Number(dateAry) - 1;
var d = Number(dateAry);
var y = Number(dateAry);
var dt = new Date(y, m, d);
if (d !== dt.getDate() || m !== dt.getMonth() || y !== dt.getFullYear())
return false; // month, day or year outside of the valid range
if (y < 2001 || y > 2004)
return false; // added line to check between 2001 and 2004
By the way: That code was actually tested and it *DOES* work. So if it doesn't work for you, you are using it wrong.
Tested 100% as is, does not work mate ??? Even the dob value matches my textbox from form but still not working ? Don't see how im using it wrong