commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rlel...@apache.org
Subject cvs commit: jakarta-commons/validator/src/javascript/org/apache/commons/validator/javascript validateRequired.js
Date Tue, 09 Sep 2003 06:19:57 GMT
rleland     2003/09/08 23:19:57

  Modified:    validator/src/javascript/org/apache/commons/validator/javascript
                        validateRequired.js
  Log:
  Bug 11520  patch supplied by Marcus Brito
  Finish applying patches to handle radio types in 'required js rule'
  
  Revision  Changes    Path
  1.4       +7 -7      jakarta-commons/validator/src/javascript/org/apache/commons/validator/javascript/validateRequired.js
  
  Index: validateRequired.js
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/validator/src/javascript/org/apache/commons/validator/javascript/validateRequired.js,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- validateRequired.js	6 Sep 2003 05:33:26 -0000	1.3
  +++ validateRequired.js	9 Sep 2003 06:19:57 -0000	1.4
  @@ -5,6 +5,7 @@
           var i = 0;
           var fields = new Array();
           oRequired = new required();
  +
           for (x in oRequired) {
               var field = form[oRequired[x][0]];
   
  @@ -12,7 +13,6 @@
                   field.type == 'textarea' ||
                   field.type == 'file' ||
                   field.type == 'select-one' ||
  -                field.type == 'radio' ||
                   field.type == 'password') {
   
                   var value = '';
  @@ -34,10 +34,7 @@
                       fields[i++] = oRequired[x][1];
                       isValid = false;
                   }
  -            }
  -            // For fields that are actually object arrays, like radio button banks,
  -            // iterate through the array and make sure something is checked
  -            if (field.length > 0) {
  +            } else if ((field.length > 0) && (field[0].type == 'radio')) {
                   isChecked=-1;
                   for (loop=0;loop < field.length;loop++) {
                       if (field[loop].checked) {
  @@ -45,7 +42,10 @@
                       }
                   }
                   if (isChecked < 0) {
  -                    fields[i++] = oRequired[x][1]
  +                    if (i == 0) {
  +                        focusField = field[0];
  +                    }
  +                    fields[i++] = oRequired[x][1];
                       isValid=false;
                   }
               }
  @@ -60,4 +60,4 @@
       // Trim whitespace from left and right sides of s.
       function trim(s) {
           return s.replace( /^\s*/, "" ).replace( /\s*$/, "" );
  -    }
  \ No newline at end of file
  +    }
  
  
  

Mime
View raw message