struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dgra...@apache.org
Subject cvs commit: jakarta-struts/conf/share validator-rules.xml
Date Wed, 07 May 2003 00:41:50 GMT
dgraham     2003/05/06 17:41:50

  Modified:    conf/share validator-rules.xml
  Log:
  Fixed minlength javascript for PR# 19594.  Also, removed
  password field checking from validateMask.
  
  Revision  Changes    Path
  1.31      +47 -40    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.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- validator-rules.xml	16 Apr 2003 04:49:38 -0000	1.30
  +++ validator-rules.xml	7 May 2003 00:41:49 -0000	1.31
  @@ -55,7 +55,7 @@
   
            <javascript><![CDATA[
               function validateRequired(form) {
  -                var bValid = true;
  +                var isValid = true;
                   var focusField = null;
                   var i = 0;
                   var fields = new Array();
  @@ -87,7 +87,7 @@
   	                            focusField = field;
   	                        }
   	                        fields[i++] = oRequired[x][1];
  -	                        bValid = false;
  +	                        isValid = false;
                           }
                       }
                   }
  @@ -95,7 +95,7 @@
                      focusField.focus();
                      alert(fields.join('\n'));
                   }
  -                return bValid;
  +                return isValid;
               }]]>
            </javascript>
   
  @@ -126,7 +126,7 @@
   
            <javascript><![CDATA[
               function validateMinLength(form) {
  -                var bValid = true;
  +                var isValid = true;
                   var focusField = null;
                   var i = 0;
                   var fields = new Array();
  @@ -136,13 +136,14 @@
                       
                       if (field.type == 'text' ||
                           field.type == 'textarea') {
  +                        
                           var iMin = parseInt(oMinLength[x][2]("minlength"));
  -                        if (field.value.length < iMin) {
  +                        if ((field.value.length > 0) && (field.value.length
< iMin)) {
                               if (i == 0) {
                                   focusField = field;
                               }
                               fields[i++] = oMinLength[x][1];
  -                            bValid = false;
  +                            isValid = false;
                           }
                       }
                   }
  @@ -150,7 +151,7 @@
                      focusField.focus();
                      alert(fields.join('\n'));
                   }
  -                return bValid;
  +                return isValid;
               }]]>
            </javascript>
   
  @@ -170,7 +171,7 @@
   
            <javascript><![CDATA[
               function validateMaxLength(form) {
  -                var bValid = true;
  +                var isValid = true;
                   var focusField = null;
                   var i = 0;
                   var fields = new Array();
  @@ -180,13 +181,14 @@
                       
                       if (field.type == 'text' ||
                           field.type == 'textarea') {
  +                        
                           var iMax = parseInt(oMaxLength[x][2]("maxlength"));
                           if (field.value.length > iMax) {
                               if (i == 0) {
                                   focusField = field;
                               }
                               fields[i++] = oMaxLength[x][1];
  -                            bValid = false;
  +                            isValid = false;
                           }
                       }
                   }
  @@ -194,7 +196,7 @@
                      focusField.focus();
                      alert(fields.join('\n'));
                   }
  -                return bValid;
  +                return isValid;
               }]]>
            </javascript>
   
  @@ -214,38 +216,37 @@
   
            <javascript><![CDATA[
               function validateMask(form) {
  -                var bValid = true;
  +                var isValid = true;
                   var focusField = null;
                   var i = 0;
                   var fields = new Array();
                   oMasked = new mask();
                   for (x in oMasked) {
  -                    if ((form[oMasked[x][0]].type == 'text' ||
  -                         form[oMasked[x][0]].type == 'textarea' ||
  -                         form[oMasked[x][0]].type == 'password') &&
  -                        (form[oMasked[x][0]].value.length > 0)) {
  -                        if (!matchPattern(form[oMasked[x][0]].value, oMasked[x][2]("mask")))
{
  +                    var field = form[oMasked[x][0]];
  +                    
  +                    if ((field.type == 'text' || 
  +                         field.type == 'textarea') && 
  +                         (field.value.length > 0)) {
  +                        
  +                        if (!matchPattern(field.value, oMasked[x][2]("mask"))) {
                               if (i == 0) {
  -                                focusField = form[oMasked[x][0]];
  +                                focusField = field;
                               }
                               fields[i++] = oMasked[x][1];
  -                            bValid = false;
  +                            isValid = false;
                           }
                       }
                   }
  +                
                   if (fields.length > 0) {
                      focusField.focus();
                      alert(fields.join('\n'));
                   }
  -                return bValid;
  +                return isValid;
               }
   
               function matchPattern(value, mask) {
  -               var bMatched = mask.exec(value);
  -               if (!bMatched) {
  -                   return false;
  -               }
  -               return true;
  +               return mask.exec(value);
               }]]>
            </javascript>
   
  @@ -779,24 +780,27 @@
   
            <javascript><![CDATA[
               function validateIntRange(form) {
  -                var bValid = true;
  +                var isValid = true;
                   var focusField = null;
                   var i = 0;
                   var fields = new Array();
                   oRange = new intRange();
                   for (x in oRange) {
  -                    if ((form[oRange[x][0]].type == 'text' ||
  -                         form[oRange[x][0]].type == 'textarea') &&
  -                        (form[oRange[x][0]].value.length > 0)) {
  +                    var field = form[oRange[x][0]];
  +                    
  +                    if ((field.type == 'text' ||
  +                         field.type == 'textarea') &&
  +                        (field.value.length > 0)) {
  +                        
                           var iMin = parseInt(oRange[x][2]("min"));
                           var iMax = parseInt(oRange[x][2]("max"));
  -                        var iValue = parseInt(form[oRange[x][0]].value);
  +                        var iValue = parseInt(field.value);
                           if (!(iValue >= iMin && iValue <= iMax)) {
                               if (i == 0) {
  -                                focusField = form[oRange[x][0]];
  +                                focusField = field;
                               }
                               fields[i++] = oRange[x][1];
  -                            bValid = false;
  +                            isValid = false;
                           }
                       }
                   }
  @@ -804,7 +808,7 @@
                       focusField.focus();
                       alert(fields.join('\n'));
                   }
  -                return bValid;
  +                return isValid;
               }]]>
            </javascript>
   
  @@ -823,24 +827,27 @@
   
            <javascript><![CDATA[
               function validateFloatRange(form) {
  -                var bValid = true;
  +                var isValid = true;
                   var focusField = null;
                   var i = 0;
                   var fields = new Array();
                   oRange = new floatRange();
                   for (x in oRange) {
  -                    if ((form[oRange[x][0]].type == 'text' ||
  -                         form[oRange[x][0]].type == 'textarea') &&
  -                        (form[oRange[x][0]].value.length > 0)) {
  +                    var field = form[oRange[x][0]];
  +                    
  +                    if ((field.type == 'text' ||
  +                         field.type == 'textarea') &&
  +                        (field.value.length > 0)) {
  +                        
                           var fMin = parseFloat(oRange[x][2]("min"));
                           var fMax = parseFloat(oRange[x][2]("max"));
  -                        var fValue = parseFloat(form[oRange[x][0]].value);
  +                        var fValue = parseFloat(field.value);
                           if (!(fValue >= fMin && fValue <= fMax)) {
                               if (i == 0) {
  -                                focusField = form[oRange[x][0]];
  +                                focusField = field;
                               }
                               fields[i++] = oRange[x][1];
  -                            bValid = false;
  +                            isValid = false;
                           }
                       }
                   }
  @@ -848,7 +855,7 @@
                       focusField.focus();
                       alert(fields.join('\n'));
                   }
  -                return bValid;
  +                return isValid;
               }]]>
            </javascript>
   
  
  
  

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


Mime
View raw message