0
  1. 我使用此代码禁用经过的时间(https://thecodedeveloper.com/disable-past-date-time/),但在我的站点上,经过时间不会变为未单击或灰色(禁用)。那么有人可以帮忙吗?

     var checkPastTime = function(inputDateTime) {
     if(typeof(inputDateTime) != "undefined" && inputDateTime !== null) {
         var current = new Date();
    
         //check past year and month
         if(inputDateTime.getFullYear() < current.getFullYear()) {
             $('.ovacrs_datetimepicker').datetimepicker('reset');
             alert("Sorry! Past date time not allow.");
         } 
         else if((inputDateTime.getFullYear() == current.getFullYear()) && (inputDateTime.getMonth() < current.getMonth())) {
             $('.ovacrs_datetimepicker').datetimepicker('reset');
             alert("Sorry! Past date time not allow.");
         }
    
         // 'this' is jquery object datetimepicker
         // check input date equal to todate date
         if (inputDateTime.getDate() == current.getDate()) {
             if(inputDateTime.getHours() < current.getHours()){
               $('.ovacrs_datetimepicker').datetimepicker('reset');
             }
             this.setOptions({
                 minTime: current.getHours() + ':00' //here pass current time hour
             });
         }
         else {
             this.setOptions({
                 minTime: false
             });
         }
     }
     };
    
     var currentYear = new Date();
     $('.ovacrs_datetimepicker').datetimepicker({
             format:'Y-m-d H:i',
             minDate : 0,
             yearStart : currentYear.getFullYear(), // Start value for current Year selector
             onChangeDateTime:checkPastTime,
             onShow:checkPastTime
     });
    
  2. 我得到了接送日期时间和下车日期时间,如何设置下车日期时间必须超过接送日期时间?我的意思是如果我选择接送日期时间是 2021 年 1 月 11 日下午 5 点,那么我不能在接送时间和下车日期之前选择吗?

4

0 回答 0