You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by rl...@apache.org on 2003/12/11 06:52:58 UTC

cvs commit: jakarta-struts/conf/share validator-rules.xml

rleland     2003/12/10 21:52:58

  Modified:    conf/share validator-rules.xml
  Log:
  Make depend on commons-validator entirely
  
  Revision  Changes    Path
  1.48      +4 -96     jakarta-struts/conf/share/validator-rules.xml
  
  Index: validator-rules.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/conf/share/validator-rules.xml,v
  retrieving revision 1.47
  retrieving revision 1.48
  diff -u -r1.47 -r1.48
  --- validator-rules.xml	17 Nov 2003 05:03:34 -0000	1.47
  +++ validator-rules.xml	11 Dec 2003 05:52:58 -0000	1.48
  @@ -59,99 +59,7 @@
                          org.apache.commons.validator.Field,
                          org.apache.struts.action.ActionMessages,
                          javax.servlet.http.HttpServletRequest"
  -                  msg="errors.required">
  -
  -         <javascript><![CDATA[
  -            function validateRequired(form) {
  -                var isValid = true;
  -                var focusField = null;
  -                var i = 0;
  -                var fields = new Array();
  -                oRequired = new required();
  -
  -                for (x in oRequired) {
  -                    var field = form[oRequired[x][0]];
  -
  -                    if (field.type == 'text' ||
  -                        field.type == 'textarea' ||
  -                        field.type == 'file' ||
  -                        field.type == 'checkbox' ||
  -                        field.type == 'select-one' ||
  -                        field.type == 'password') {
  -
  -                        var value = '';
  -                        // get field's value
  -                        if (field.type == "select-one") {
  -                            var si = field.selectedIndex;
  -                            if (si >= 0) {
  -                                value = field.options[si].value;
  -                            }
  -                        } else if (field.type == 'checkbox') {
  -			    if (field.checked) {
  -			        value = field.value;
  -			    }
  -                    } else {
  -                            value = field.value;
  -                        }
  -
  -                        if (trim(value).length == 0) {
  -
  -                            if (i == 0) {
  -                                focusField = field;
  -                            }
  -                            fields[i++] = oRequired[x][1];
  -                            isValid = false;
  -                        }
  -                    } else if (field.type == "select-multiple") {
  -                        var numOptions = field.options.length;
  -                        lastSelected=-1;
  -                        for(loop=numOptions-1;loop>=0;loop--) {
  -                            if(field.options[loop].selected) {
  -                                lastSelected = loop;
  -                                value = field.options[loop].value;
  -                                break;
  -                            }
  -                        }
  -                        if(lastSelected < 0 || trim(value).length == 0) {
  -                            if(i == 0) {
  -                                focusField = field;
  -                            }
  -                            fields[i++] = oRequired[x][1];
  -                            isValid=false;
  -                        }
  -                    } else if ((field.length > 0) && (field[0].type == 'radio' || field[0].type == 'checkbox')) {
  -                        isChecked=-1;
  -                        for (loop=0;loop < field.length;loop++) {
  -                            if (field[loop].checked) {
  -                                isChecked=loop;
  -                                break; // only one needs to be checked
  -                            }
  -                        }
  -                        if (isChecked < 0) {
  -                            if (i == 0) {
  -                                focusField = field[0];
  -                            }
  -                            fields[i++] = oRequired[x][1];
  -                            isValid=false;
  -                        }
  -                    }
  -                }
  -                if (fields.length > 0) {
  -                   focusField.focus();
  -                   alert(fields.join('\n'));
  -                }
  -                return isValid;
  -            }
  -
  -            // Trim whitespace from left and right sides of s.
  -            function trim(s) {
  -                return s.replace( /^\s*/, "" ).replace( /\s*$/, "" );
  -            }
  -
  -            ]]>
  -         </javascript>
  -
  -      </validator>
  +                  msg="errors.required"/>
   
         <validator name="requiredif"
                    classname="org.apache.struts.validator.FieldChecks"
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org