From 290e64de9782acd32f3881c1269792717c53f333 Mon Sep 17 00:00:00 2001
From: Benard Ebinu
Date: Mon, 15 Jan 2018 14:50:01 -0800
Subject: [PATCH] DIV-691,DIV-696: only allow positive integers when user
enters number of children
---
edivorce/apps/core/static/js/main.js | 10 ++++++++++
.../core/templates/question/06_children_facts.html | 4 ++--
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/edivorce/apps/core/static/js/main.js b/edivorce/apps/core/static/js/main.js
index 27f906c2..9aafe4fc 100755
--- a/edivorce/apps/core/static/js/main.js
+++ b/edivorce/apps/core/static/js/main.js
@@ -599,6 +599,16 @@ $(function () {
$(this).val(value.toFixed(2));
});
+ $('.positive-integer').on('keypress', function(e) {
+ // keyCode [95-105] - number page
+ // keyCode [48-57] - 0-9
+ // keyCode [8] - backspace
+ // keyCode [37-40] - directional arrows
+ if (!((e.which > 95 && e.which < 106) || (e.which > 47 && e.which < 58) || e.which === 8 || (e.keyCode > 36 && e.keyCode < 41))) {
+ e.preventDefault();
+ }
+ });
+
$('.fact-sheet-input').on('focus', function() {
$(this).closest('td').addClass('table-cell-active');
}).on('focusout', function() {
diff --git a/edivorce/apps/core/templates/question/06_children_facts.html b/edivorce/apps/core/templates/question/06_children_facts.html
index f9b923cc..c3fdf904 100644
--- a/edivorce/apps/core/templates/question/06_children_facts.html
+++ b/edivorce/apps/core/templates/question/06_children_facts.html
@@ -244,7 +244,7 @@
(the child spends at least 40 percent of the time with each of you in a year). If you and your spouse
have a split parenting arrangement for any other children, do not include them in this set of questions.
- {% input_field type="number" name="number_of_children" class="form-control input-narrow" min="0" %}
+ {% input_field type="number" name="number_of_children" class="form-control input-narrow positive-integer" min="0" %}
@@ -582,7 +582,7 @@
How many child(ren) are 19 years or older for whom you are asking for support?
- {% input_field type="number" name="number_children_over_19_need_support" class="fact-sheet-input input-narrow" %}
+ {% input_field type="number" name="number_children_over_19_need_support" class="fact-sheet-input input-narrow positive-integer" %}