我想验证日历作为出发和目的地日期和日期不应小于出发日期

i want to validate calender as departure and destination date and date should not be less than departure date?

本文关键字:日期 出发 小于 目的地 验证 日历      更新时间:2023-09-26
<html>
  <body>
   <input type="date" class="form-control" name="date" value="" id="departuredate"/>
   <input type="date" class="form-control" name="date_arrival" id="arrivaldate" value="" />
  </body>
</html>

这是给出日期的代码。我想将日历验证为departuredestination日期。destination日期不小于departure日期

在此代码之前包含jquery,并在表单提交时调用以下代码:

<script>
    var startDate = new Date($('#departuredate').val());
    var endDate = new Date($('#arrivaldate').val());
    if (startDate < endDate){
    alert("date shoul be geater");
    }
    </script>