You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by rl...@apache.org on 2003/09/06 07:33:26 UTC

cvs commit: jakarta-commons/validator/src/javascript/org/apache/commons/validator/javascript validateRequired.js

rleland     2003/09/05 22:33:26

  Modified:    validator/src/javascript/org/apache/commons/validator/javascript
                        validateRequired.js
  Log:
  Add ability to use required condition on array types like
  checkboxes.
  This was a Bug enhancement I though I committed,
  evidently I did a CVS update.
  
  Revision  Changes    Path
  1.3       +14 -0     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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- validateRequired.js	25 Jun 2003 01:14:22 -0000	1.2
  +++ validateRequired.js	6 Sep 2003 05:33:26 -0000	1.3
  @@ -35,6 +35,20 @@
                       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) {
  +                isChecked=-1;
  +                for (loop=0;loop < field.length;loop++) {
  +                    if (field[loop].checked) {
  +                        isChecked=loop;
  +                    }
  +                }
  +                if (isChecked < 0) {
  +                    fields[i++] = oRequired[x][1]
  +                    isValid=false;
  +                }
  +            }
           }
           if (fields.length > 0) {
              focusField.focus();