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

Date Validation 1

Status
Not open for further replies.

curt62

Programmer
Feb 13, 2003
12
US
I am attempting to validate that a date entered in child form falls within a week ending date in a parent form. My alert works for the second part of the evaluation but not the first part. In other words, I get the alert if the date is greater than "self.opener.document._TimeSheet.WeekEnding1.value" but not if it is less than "date2". I know that I am getting a good value for "date2" because if I unremark the "//alert(date2);" it returns the date 6 days prior to "self.opener.document._TimeSheet.WeekEnding1.value" which is exactly what I want.

Can anyone tell what I am doing wrong here?

var date1 = new Date(self.opener.document._TimeSheet.WeekEnding1.value );
var date2 = new Date( date1.setDate(date1.getDate()-6)) ;
//alert(date2);

if (f.twField0.value < date2 ||f.twField0.value>self.opener.document._TimeSheet.WeekEnding1.value){alert(&quot;Date needs to fall within 1st Week&quot;); return false};
 
try f.twField0.value < date2.Date or f.twField0.value < date2.DateValue
 
tried &quot;f.twField0.value < date2.Date&quot; and&quot;f.twField0.value < date2.DateValue&quot; No luck yet.

Thanks for trying.
 
the problem here is that f.twField0.value is a string and we cant compare it to the date2.Date
try this var date3= new Date(f.twField0.value)


then try if date3< date2.Date or date3< date2.DateValue
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top