diff --git a/static/js/user_profile.js b/static/js/user_profile.js index d1d3f30..515d1bf 100644 --- a/static/js/user_profile.js +++ b/static/js/user_profile.js @@ -594,6 +594,22 @@ function hideMenu(event) { } +function checkDate() { + var dateDeparture = document.getElementById('id_departure_DT'); + let dateArrival = document.getElementById('id_arrival_DT'); + var DateStart = new Date(dateDeparture.value); + var DateEnd = new Date(dateArrival.value); + if (DateEnd < DateStart) { + + alert("End date cannot be less than Start date."); + dateArrival.value = "" + + + } + return true; + +} + diff --git a/templates/blocks/profile/b_new_route.html b/templates/blocks/profile/b_new_route.html index 84f9aba..cd44ee8 100644 --- a/templates/blocks/profile/b_new_route.html +++ b/templates/blocks/profile/b_new_route.html @@ -64,6 +64,7 @@ type="datetime-local" min= {% now "Y-m-d" %}T{% now "H:i" %} name="departure_DT" + onchange="checkDate()" {% if form.fields.departure_DT.required %} required{% endif %} id="id_departure_DT" class="el_form_b_new_route" @@ -81,6 +82,7 @@ type="datetime-local" min= {% now "Y-m-d" %}T{% now "H:i" %} name="arrival_DT" + onchange="checkDate()" {% if form.fields.arrival_DT.required %} required{% endif %} id="id_arrival_DT" class="el_form_b_new_route"