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

时间:2015-06-03 09:07:00

标签: javascript php

<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日期

1 个答案:

答案 0 :(得分:1)

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

<script>
    var startDate = new Date($('#departuredate').val());
    var endDate = new Date($('#arrivaldate').val());

    if (startDate < endDate){
    alert("date shoul be geater");
    }
    </script>