From 0a2019e83316ee50f04a99621de66f574f8ca27e Mon Sep 17 00:00:00 2001 From: ArtemB Date: Tue, 29 Aug 2023 17:27:21 +0300 Subject: [PATCH 1/2] 0.0.119 reset arrival datetime-local --- static/js/user_profile.js | 16 ++++++++++++++++ templates/blocks/profile/b_new_route.html | 2 ++ 2 files changed, 18 insertions(+) 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" From 3312b825fce4a8128734becfe5451a9c8ac90b6e Mon Sep 17 00:00:00 2001 From: ArtemB Date: Tue, 29 Aug 2023 17:53:40 +0300 Subject: [PATCH 2/2] 0.0.120 error message for wrong data in arrival --- static/js/user_profile.js | 9 ++++++++- templates/blocks/profile/b_new_route.html | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/static/js/user_profile.js b/static/js/user_profile.js index 515d1bf..e4403ea 100644 --- a/static/js/user_profile.js +++ b/static/js/user_profile.js @@ -601,9 +601,16 @@ function checkDate() { var DateEnd = new Date(dateArrival.value); if (DateEnd < DateStart) { - alert("End date cannot be less than Start date."); + // alert("End date cannot be less than Start date."); dateArrival.value = "" + let arrivalDiv = document.getElementById('arrival_div') + let errorMessage = document.createElement('span'); + errorMessage.textContent = "Дата прибытия, не может быть установлена раньше даты отправки" + errorMessage.classList.add('errorlist') + arrivalDiv.appendChild(errorMessage); + + } return true; diff --git a/templates/blocks/profile/b_new_route.html b/templates/blocks/profile/b_new_route.html index cd44ee8..b842e6f 100644 --- a/templates/blocks/profile/b_new_route.html +++ b/templates/blocks/profile/b_new_route.html @@ -76,7 +76,7 @@ {% endif %} -
+