diff --git a/cara/apps/calculator/static/css/form.css b/cara/apps/calculator/static/css/form.css
index 3c048765..6a936803 100644
--- a/cara/apps/calculator/static/css/form.css
+++ b/cara/apps/calculator/static/css/form.css
@@ -6,6 +6,10 @@
color: black;
}
-.red {
+.red_border {
box-shadow: 0px 0px 2px 1px red;
+}
+
+.red_text {
+ color: red;
}
\ No newline at end of file
diff --git a/cara/apps/calculator/static/js/form.js b/cara/apps/calculator/static/js/form.js
index 259cce35..33106522 100644
--- a/cara/apps/calculator/static/js/form.js
+++ b/cara/apps/calculator/static/js/form.js
@@ -160,12 +160,28 @@ function validate_form(form) {
//Validate all dates
$("input[required].datepicker").each(function () {
- $(this).removeClass("red");
+ $(this).removeClass("red_border");
+ $(this).next().hide();
var fromDate = $(this).val();
if (!isValidDate(fromDate)) {
- $(this).addClass("red");
+ $(this).addClass("red_border");
submit = false;
+ $(this).next().show();
+ }
+ });
+
+ //Validate all times
+ $("input[required].finish_time").each(function () {
+ $(this).removeClass("red_border");
+ $(this).next().hide();
+
+ var startTime = parseValToNumber($(this).prev());
+ var finishTime = parseValToNumber($(this));
+ if (startTime > finishTime) {
+ $(this).addClass("red_border");
+ submit = false;
+ $(this).next().show();
}
});
@@ -183,6 +199,10 @@ function isValidDate(date) {
return composedDate.getDate() == d && composedDate.getMonth() + 1 == m && composedDate.getFullYear() == y;
}
+function parseValToNumber(obj) {
+ return parseInt(obj.val().replace(':',''), 10);
+}
+
/* ------ On Load ---------- */
$(document).ready(function () {
diff --git a/cara/apps/calculator/templates/calculator.form.html.j2 b/cara/apps/calculator/templates/calculator.form.html.j2
index 74f3c3f7..d255f814 100644
--- a/cara/apps/calculator/templates/calculator.form.html.j2
+++ b/cara/apps/calculator/templates/calculator.form.html.j2
@@ -80,22 +80,25 @@ Beta v1.0.0 Please send feedback to
Number of infected people:
Activity type:
Start:
- Finish:
+ Finish:
+ Finish time must be after start
Infected person(s) presence:
Start:
- Finish:
+ Finish:
+ Finish time must be after start
+
-
When is the event?
-
+
+ Incorrect date format
Activity type: {% if form.activity_type == "office" %} - Office work – typical scenario with all persons seated, talking. + Office/Meeting – typical scenario with all persons seated, talking. {% elif form.activity_type == "workshop" %} Workshop = assembly workshop environment, all persons doing light exercise, talking. {% elif form.activity_type == "training" %}