From a96a8811452c790510b68e8ce81ca8e7b8f41f6a Mon Sep 17 00:00:00 2001 From: gaazzopa Date: Mon, 16 Nov 2020 22:19:06 +0100 Subject: [PATCH] Preserve lunch times on back button --- cara/apps/calculator/static/js/form.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cara/apps/calculator/static/js/form.js b/cara/apps/calculator/static/js/form.js index a678f0ac..cc35000f 100644 --- a/cara/apps/calculator/static/js/form.js +++ b/cara/apps/calculator/static/js/form.js @@ -290,7 +290,9 @@ $(document).ready(function () { //Same for lunch option var lunch_option = $("input[name='lunch_option']:checked"); - require_fields(lunch_option); + var option = (lunch_option.attr('id') === "lunch_option_yes") + $("#lunch_start").prop('required', option); + $("#lunch_finish").prop('required', option); // Setup the maximum number of people at page load (to handle back/forward), // and update it when total people is changed. @@ -305,7 +307,7 @@ $(document).ready(function () { //Validate all finish times $("input[required].finish_time").each(function() {validateFinishTime(this)}); $(".finish_time").change(function() {validateFinishTime(this)}); - $(".start_time").change(function() {validateStartTime()}); + $(".start_time").change(validateStartTime); $("#event_type_recurrent").change(removeInvalidDate);