diff --git a/cara/apps/calculator/static/js/form.js b/cara/apps/calculator/static/js/form.js index ef5f29d8..971b9ba6 100644 --- a/cara/apps/calculator/static/js/form.js +++ b/cara/apps/calculator/static/js/form.js @@ -153,7 +153,17 @@ function require_hepa(option) { } function setMaxInfectedPeople() { - $("#infected_people").attr("max", $("#total_people").val()); + + $("#training_limit_error").hide(); + var max = $("#total_people").val() + + if ($("#activity_type").val() === "training") + { + max = 1; + $("#training_limit_error").show(); + } + + $("#infected_people").attr("max", max); } /* -------UI------- */ @@ -251,6 +261,8 @@ $(document).ready(function () { setMaxInfectedPeople(); $("#total_people").change(setMaxInfectedPeople); + $("#activity_type").change(setMaxInfectedPeople); + var radioValue = $("input[name='event_type']:checked"); if (radioValue.val()) { require_fields(radioValue.get(0)); diff --git a/cara/apps/calculator/templates/calculator.form.html.j2 b/cara/apps/calculator/templates/calculator.form.html.j2 index 7d9ddb85..83b0eb0c 100644 --- a/cara/apps/calculator/templates/calculator.form.html.j2 +++ b/cara/apps/calculator/templates/calculator.form.html.j2 @@ -106,6 +106,7 @@
Total number of occupants:
Number of infected people:
+

Activity type: