KMAIN-1850 Date of Birth Is Mandatory
authorNick Duncan <nDuncan@catalystitservices.com>
Mon, 28 Sep 2015 22:55:23 +0000 (18:55 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
User Is Now Unable To Bypass The Required Date Of Birth Field
During Patron Registration

Signed-off-by: Nick Duncan <nDuncan@catalystitservices.com>
Signed-off-by: Bill Erickson <berickxx@gmail.com>
berick: repaired merge conflict; minor formatting repairs

Conflicts:
Open-ILS/web/js/ui/default/actor/user/register.js

Open-ILS/web/js/ui/default/actor/user/register.js

index c455168..4f52387 100644 (file)
@@ -1465,6 +1465,9 @@ function attachWidgetEvents(fmcls, fmfield, widget) {
                 if(this.attr('disabled') || this.attr('readOnly')) {
                     return true;
                 }
+                if(!this.attr('value')) {
+                    return false;
+                }
                 if(orgSettings['ui.patron.edit.ac.barcode.regex']) { // This serves as a master "on" for these checks
                     // No spaces
                     if(this.attr("value").match(/\s/)) {
@@ -1596,8 +1599,22 @@ function attachWidgetEvents(fmcls, fmfield, widget) {
 
             case 'dob':
                 widget.widget.isValid = function() {
-                    if(!this.attr('value')) return false;
-                    if(this.attr('value').getFullYear().toString().length < 4) return false;
+                    // KCLS requires DoB.
+                    // We're not just using ui.patron.edit.au.dob.require,
+                    // because when the DoB is unset, we also want to
+                    // clear the juvenile flag.
+                    if(!this.attr('value')) {
+                        findWidget('au', 'juvenile').widget.attr('value', false);
+                        return false;
+                    }
+
+                    // DoB year <= 999 suggests human error; reject it.
+                    if(this.attr('value').getFullYear().toString().length < 4) {
+                        findWidget('au', 'juvenile').widget.attr('value', false);
+                        return false;
+                    }
+
+                    // DoB cannot be in the future
                     return this.attr("value") < new Date();
                 };
                 dojo.connect(widget.widget, 'onChange',