jQuery validate date field for seperate year, month, date

谁都会走 提交于 2019-12-25 02:22:57

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!