简体   繁体   中英

jQuery validate date field for seperate year, month, date

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:

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;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM