JavaScript date comparison

Results 1 to 2 of 2

Thread: JavaScript date comparison

  1. #1
    Join Date
    Dec 1969

    Default JavaScript date comparison

    if (form1.StartDate.value &#062; form1.EndDate.value)<BR> { alert("Start Date Must Be Prior To End Date");<BR> return(false); <BR>} <BR>If I put 10/06/2000 in StartDate and 10/03/2001 in EndDate fields, ALERT message pops up. <BR>Even though by date StartDate is prior to EndDate<BR>How do I force it to do DATE comparison ?

  2. #2
    Join Date
    Dec 1969

    Default RE: JavaScript date comparison

    They aren&#039;t date objects, they&#039;re strings...<BR><BR>var1 = new Date();<BR>var2 = new Date()<BR><BR>var1 = field1;<BR>var2 = field2;<BR><BR>if (var1 &#062; var2)<BR><BR>It&#039;s been awhile since I&#039;ve done JS dates (and I&#039;m language switching a LOT right now) but this syntax should be close enough for you to figure out.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts