allowing -'s in barcode
[Evergreen.git] / Evergreen / xul / staff_client / server / patron / ue_config.js
index 9c7b54b..7f24f8a 100644 (file)
@@ -39,7 +39,8 @@ var myPerms = [
 
 var dataFields;
 const numRegex         = /^\d+$/;
-const wordRegex        = /^\w+$/;
+const wordRegex        = /^[\w-]+$/;
+const unameRegex       = /^\w[\.\w\@-]*$/;
 const ssnRegex         = /^\d{3}-\d{2}-\d{4}$/;
 const dlRegex          = /^[a-zA-Z]{2}-\w+/; /* driver's license */
 const phoneRegex       = /^\d{3}-\d{3}-\d{4}(| ex\d+)$/i;
@@ -77,6 +78,7 @@ function uEditUsrnameBlur(field) {
 function uEditBarcodeBlur(field) {
        var barcode = uEditNodeVal(field);
        if(!barcode) return;
+       _debug("blurring card with new value " + barcode);
        var req = new Request(CHECK_BARCODE, SESSION, barcode);
        req.callback( 
                function(r) {
@@ -126,7 +128,7 @@ function uEditDefineData(patron) {
                        errkey  : 'ue_bad_username',
                        widget  : {
                                id              : 'ue_username',
-                               regex   : wordRegex,
+                               regex   : unameRegex,
                                type    : 'input',
                                onblur : uEditUsrnameBlur
                        }
@@ -159,6 +161,11 @@ function uEditDefineData(patron) {
                                        var pw1f = uEditFindFieldByWId('ue_password1');
                                        var pw1 = uEditNodeVal(pw1f);
                                        field.widget.regex = new RegExp('^'+pw1+'$');
+                                       if( pw1 ) field.required = true;
+                                       else {
+                                               if(!patron.isnew())
+                                                       field.required = false;
+                                       }
                                }
                        }
                },
@@ -428,6 +435,7 @@ function uEditDefineData(patron) {
                                id                      : 'ue_claims_returned',
                                type            : 'input',
                                regex           : numRegex,
+                               disabled : true
                        }
                },
                {
@@ -1027,8 +1035,7 @@ function uEditCheckDOB(field) {
        __lastdob = dob;
 
        var parts = dob.split(/-/);
-       var d = new Date( parts[0], parts[1] - 1, parts[2] );
-
+       parts[2] = parts[2].replace(/[T ].*/,'');
        dob = buildDate( parts[0], parts[1], parts[2] );
 
        var today = new Date();