KMAIN-1830 Backspace clears patron register barcode
authorNick Duncan <nDuncan@catalystitservices.com>
Mon, 28 Sep 2015 22:36:35 +0000 (18:36 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
Backspace Now Completely Clears Barcode Field When Doing A
Patron Registration.

Signed-off-by: Nick Duncan <nDuncan@catalystitservices.com>
Modified by Bill E. for style, to avoid unnecessary dojo.attach, and
to add some comments.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/web/js/ui/default/actor/user/register.js

index c575f23..9b95e75 100644 (file)
@@ -1542,6 +1542,20 @@ function attachWidgetEvents(fmcls, fmfield, widget) {
                     );
                 }
             );
+
+            // when creating a new patron, a backspace in the barcode
+            // entry field clears the barcode and username values.
+            if (patron.isnew()) {
+                dojo.connect(dojo.byId("barcode"), "onkeypress", 
+                    function(event) {
+                        if (event.keyCode != 8) return // 8 = Backspace Key
+                        findWidget('au', 'usrname').widget.attr('value', '');
+                        findWidget('ac', 'barcode').widget.attr('value', '');
+                        findWidget('ac', 'barcode').widget.attr('required', true);
+                    }
+                );
+            }
+
             return;
         }
     }