0

我的下拉菜单的值为“一年”,“两年”,......等等。好吗?我也有两个带有日历扩展器的 ajax 文本框。如果下拉选择的值为“一年”并且两个文本框值之间的持续时间意味着日期不匹配,我想弹出警报消息。明白我的意思吗?请帮我。

4

1 回答 1

0

算法 :
1.从文本框中获取两个日期。
2. 查找每个日期的纪元时间。//
3.减去两个日期。
4.subtract_result = 365*24*60*60 // 查找 1 年的时间戳值
5. 所以,如果差值超过上面的计算,你可以确定日期不匹配。
 

// This is for first date first = new Date(2010, 03, 08, 15, 30, 10); // Get the first date epoch object // document.write((first.getTime())/1000); // get the actual epoch values second = new Date(2012, 03, 08, 15, 30, 10); // Get the first date epoch object //document.write((second.getTime())/1000); // get the actual epoch values diff= second - first ; one_day_epoch = 24*60*60 ; // calculating one epoch if ( diff/ one_day_epoch > 365 ) // check , is it exceei { alert( 'date is exceeding one year'); }
于 2010-03-08T09:06:41.037 回答