Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with checking dates

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hello i was using the following code to check for bad dates. However it evaluates 32/32/32 and 1/1/1 to be valid dates. Can the date object once loaded tell me if its a correct date. Or is the only way to check the date is to break it up into mm dd yyyy and check each portion for validity.

function goodDate()
{
var fromDate = FrontPage_Form1.DatePeriodfrom.value;
var toDate = FrontPage_Form1.DatePeriodTo.value;
testFrom = new Date(fromDate);
testTo = new Date(toDate);
if (fromDate != "" && toDate != "")
{
if (testFrom == "NaN" || testTo == "NaN")
{
alert("bad date");
}
}
}

howard

 
Hi howard,

I posted a FAQ on "checking date format" in this forum, just take a look at it, I think that it will help you ;-)

Hope this helps ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top