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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

date problem - need to compare form date to current date

Status
Not open for further replies.

tterrapin

Programmer
Jan 18, 2001
12
CA
Can someone tell me how to compare a date from a form to the current system date. I've tried coding this several ways and keep getting errors.

What I have is a form with 3 drop down boxes to determine a date. Dropdown boxes for Day is 01-31, Month is "January - December" and Year is 2000-2002. I validate the month and the day combindation and then string the 3 fields together to get the date entered - it's in the following format eg: "August 14, 2001"

here is the code:

datein = frmMonth+" "+frmDay+", "+frmYear // fields from form
today = new Date();

if (expiry.getTime() > today.getTime()) {
alert("This expiry date can not be greater than current date."); document.frmAddCourse.Day.focus();
return (false);
}

This code works fine if current date is anything other than = to expiry date. If the two dates are equal if falls into the error logic.

Thanks

Tterrapin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top