Treat empty username as invalid in user editor
authorJeff Godin <jgodin@tadl.org>
Wed, 30 Oct 2013 19:29:24 +0000 (15:29 -0400)
committerBen Shum <bshum@biblio.org>
Thu, 9 Jan 2014 23:02:58 +0000 (18:02 -0500)
There seems to be undesired interaction between the required
attribute and the isValid method on a dojo/dijit ValidationTextBox.
If both are set, isValid needs to check for an empty value,
otherwise the field is considered valid the moment it gains focus.

We don't want an empty username to be considered valid, because we
know that we will be unable to save the user.

We can work around this by teaching the isValid function to consider
an empty value as invalid.

Signed-off-by: Jeff Godin <jgodin@tadl.org>
Signed-off-by: Melissa Ceraso <mceraso@biblio.org>
Signed-off-by: Ben Shum <bshum@biblio.org>
Open-ILS/web/js/ui/default/actor/user/register.js

index aabdc3c..daccc51 100644 (file)
@@ -1347,6 +1347,10 @@ function attachWidgetEvents(fmcls, fmfield, widget) {
 
             case 'usrname':
                 widget.widget.isValid = function() {
+                    // Not empty
+                    if(this.attr("value") == '') {
+                        return false;
+                    }
                     // No spaces
                     if(this.attr("value").match(/\s/)) {
                         return false;