问题
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:
回答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;
}
来源:https://stackoverflow.com/questions/20040267/jquery-validate-date-field-for-seperate-year-month-date