0

I have 3 separate fields separatly for from and two date. Year, month, Date have the drop down lists for the options to select. I would like to validate the form so that To > From. How can I implement it??

From

Year:

Month:

Date:

To

Year:

Month:

Date:
Haji
  • 1,999
  • 1
  • 15
  • 21
Sam
  • 5,040
  • 12
  • 43
  • 95
  • Possible duplicate with http://stackoverflow.com/questions/7396526/date-now-greater-than-date-value-given http://stackoverflow.com/questions/14439471/jquery-function-to-compare-date-with-current-date – raf Nov 18 '13 at 04:53
  • @Joe - do the answers of those questions resolve your issue? Is there anything else you are after? – Chandranshu Nov 18 '13 at 05:00
  • Kindly understand my requirement. I dont have all the fields yyyy/mm/dd in a single box. I have 3 boxes for from and 3 boxes for to (Totally 6 boxes). Each boxes have seperate ids – Sam Nov 18 '13 at 05:04

1 Answers1

1

You can get value from that 6 fields and arrange them shown below:

date_from=new Date('FROM_YEAR','FROM_MONTH','FROM_DAY');
date_from =  date_from.getTime();

date_to=new Date('TO_YEAR','TO_MONTH','TO_DAY');
date_to =  date_to.getTime();

if(date_from > date_to)
{
    alert("Please enter valid date");
    return false;
}
Parixit
  • 3,829
  • 3
  • 37
  • 61