From b32e81b052bd42ca5093fb00c945e2ff2b19f59b Mon Sep 17 00:00:00 2001 From: Luis Aleixo Date: Mon, 29 Nov 2021 14:06:03 +0100 Subject: [PATCH] Moved required fields logic to js --- cara/apps/calculator/static/js/form.js | 10 ++++++++-- cara/apps/calculator/templates/calculator.form.html.j2 | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/cara/apps/calculator/static/js/form.js b/cara/apps/calculator/static/js/form.js index 12086af1..5a20f025 100644 --- a/cara/apps/calculator/static/js/form.js +++ b/cara/apps/calculator/static/js/form.js @@ -239,8 +239,14 @@ function on_ventilation_type_change() { function on_wearing_mask_change() { wearing_mask = $('input[type=radio][name=mask_wearing_option]') wearing_mask.each(function (index) { - if (this.checked) getChildElement($(this)).show(); - else getChildElement($(this)).hide(); + if (this.checked) { + getChildElement($(this)).show(); + require_fields(this); + } + else { + getChildElement($(this)).hide(); + require_fields(this); + } }) } diff --git a/cara/apps/calculator/templates/calculator.form.html.j2 b/cara/apps/calculator/templates/calculator.form.html.j2 index 92cd6b5e..9b73d9fd 100644 --- a/cara/apps/calculator/templates/calculator.form.html.j2 +++ b/cara/apps/calculator/templates/calculator.form.html.j2 @@ -260,9 +260,9 @@
Are masks worn when occupants are at workstations?
- + - +