commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nia...@apache.org
Subject svn commit: r367249 - in /jakarta/commons/proper/validator/trunk: src/javascript/org/apache/commons/validator/javascript/ xdocs/
Date Mon, 09 Jan 2006 08:51:19 GMT
Author: niallp
Date: Mon Jan  9 00:50:59 2006
New Revision: 367249

URL: http://svn.apache.org/viewcvs?rev=367249&view=rev
Log:
Fix for Bug 14471 - Change JavaScript validators so that they don't fail when field is missing
- reported by Andrew Berridge, patch from Paul Benedict

Modified:
    jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateByte.js
    jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateCreditCard.js
    jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateDate.js
    jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateEmail.js
    jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateFloat.js
    jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateFloatRange.js
    jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateIntRange.js
    jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateInteger.js
    jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateMask.js
    jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateMaxLength.js
    jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateMinLength.js
    jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateRequired.js
    jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateShort.js
    jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateUtilities.js
    jakarta/commons/proper/validator/trunk/xdocs/changes.xml

Modified: jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateByte.js
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateByte.js?rev=367249&r1=367248&r2=367249&view=diff
==============================================================================
--- jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateByte.js
(original)
+++ jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateByte.js
Mon Jan  9 00:50:59 2006
@@ -19,6 +19,9 @@
                 continue;
             }
             var field = form[oByte[x][0]];
+            if (!jcv_isFieldPresent(field)) {
+              continue;
+            }
 
             if ((field.type == 'hidden' ||
                 field.type == 'text' ||

Modified: jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateCreditCard.js
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateCreditCard.js?rev=367249&r1=367248&r2=367249&view=diff
==============================================================================
--- jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateCreditCard.js
(original)
+++ jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateCreditCard.js
Mon Jan  9 00:50:59 2006
@@ -18,13 +18,17 @@
             if (!jcv_verifyArrayElement(x, oCreditCard[x])) {
                 continue;
             }
-            if ((form[oCreditCard[x][0]].type == 'text' ||
-                 form[oCreditCard[x][0]].type == 'textarea') &&
-                (form[oCreditCard[x][0]].value.length > 0)  &&
-                 form[oCreditCard[x][0]].disabled == false) {
-                if (!luhnCheck(form[oCreditCard[x][0]].value)) {
+            var field = form[oCreditCard[x][0]];
+            if (!jcv_isFieldPresent(field)) {
+              continue;
+            }
+            if ((field.type == 'text' ||
+                 field.type == 'textarea') &&
+                (field.value.length > 0)  &&
+                 field.disabled == false) {
+                if (!luhnCheck(field.value)) {
                     if (i == 0) {
-                        focusField = form[oCreditCard[x][0]];
+                        focusField = field;
                     }
                     fields[i++] = oCreditCard[x][1];
                     bValid = false;

Modified: jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateDate.js
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateDate.js?rev=367249&r1=367248&r2=367249&view=diff
==============================================================================
--- jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateDate.js
(original)
+++ jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateDate.js
Mon Jan  9 00:50:59 2006
@@ -19,6 +19,9 @@
                 continue;
             }
            var field = form[oDate[x][0]];
+           if (!jcv_isFieldPresent(field)) {
+             continue;
+           }
            var value = field.value;
            var isStrict = true;
            var datePattern = oDate[x][2]("datePatternStrict");

Modified: jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateEmail.js
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateEmail.js?rev=367249&r1=367248&r2=367249&view=diff
==============================================================================
--- jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateEmail.js
(original)
+++ jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateEmail.js
Mon Jan  9 00:50:59 2006
@@ -19,6 +19,9 @@
                 continue;
             }
             var field = form[oEmail[x][0]];
+            if (!jcv_isFieldPresent(field)) {
+              continue;
+            }
             if ((field.type == 'hidden' || 
                  field.type == 'text' ||
                  field.type == 'textarea') &&

Modified: jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateFloat.js
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateFloat.js?rev=367249&r1=367248&r2=367249&view=diff
==============================================================================
--- jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateFloat.js
(original)
+++ jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateFloat.js
Mon Jan  9 00:50:59 2006
@@ -18,6 +18,9 @@
                 continue;
             }
         	var field = form[oFloat[x][0]];
+            if (!jcv_isFieldPresent(field)) {
+              continue;
+            }
         	
             if ((field.type == 'hidden' ||
                 field.type == 'text' ||

Modified: jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateFloatRange.js
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateFloatRange.js?rev=367249&r1=367248&r2=367249&view=diff
==============================================================================
--- jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateFloatRange.js
(original)
+++ jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateFloatRange.js
Mon Jan  9 00:50:59 2006
@@ -18,6 +18,9 @@
                 continue;
             }
             var field = form[oRange[x][0]];
+            if (!jcv_isFieldPresent(field)) {
+              continue;
+            }
             
             if ((field.type == 'hidden' ||
                 field.type == 'text' || field.type == 'textarea') &&

Modified: jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateIntRange.js
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateIntRange.js?rev=367249&r1=367248&r2=367249&view=diff
==============================================================================
--- jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateIntRange.js
(original)
+++ jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateIntRange.js
Mon Jan  9 00:50:59 2006
@@ -18,6 +18,9 @@
                 continue;
             }
             var field = form[oRange[x][0]];
+            if (!jcv_isFieldPresent(field)) {
+              continue;
+            }
             if (field.disabled == false)  {
                 var value = '';
                 if (field.type == 'hidden' ||

Modified: jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateInteger.js
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateInteger.js?rev=367249&r1=367248&r2=367249&view=diff
==============================================================================
--- jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateInteger.js
(original)
+++ jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateInteger.js
Mon Jan  9 00:50:59 2006
@@ -18,6 +18,9 @@
                 continue;
             }
             var field = form[oInteger[x][0]];
+            if (!jcv_isFieldPresent(field)) {
+              continue;
+            }
 
             if ((field.type == 'hidden' ||
                 field.type == 'text' ||

Modified: jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateMask.js
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateMask.js?rev=367249&r1=367248&r2=367249&view=diff
==============================================================================
--- jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateMask.js
(original)
+++ jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateMask.js
Mon Jan  9 00:50:59 2006
@@ -18,6 +18,9 @@
                 continue;
             }
             var field = form[oMasked[x][0]];
+            if (!jcv_isFieldPresent(field)) {
+              continue;
+            }
 
             if ((field.type == 'hidden' ||
                 field.type == 'text' ||

Modified: jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateMaxLength.js
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateMaxLength.js?rev=367249&r1=367248&r2=367249&view=diff
==============================================================================
--- jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateMaxLength.js
(original)
+++ jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateMaxLength.js
Mon Jan  9 00:50:59 2006
@@ -21,6 +21,9 @@
                 continue;
             }
             var field = form[oMaxLength[x][0]];
+            if (!jcv_isFieldPresent(field)) {
+              continue;
+            }
 
             if ((field.type == 'hidden' ||
                 field.type == 'text' ||

Modified: jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateMinLength.js
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateMinLength.js?rev=367249&r1=367248&r2=367249&view=diff
==============================================================================
--- jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateMinLength.js
(original)
+++ jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateMinLength.js
Mon Jan  9 00:50:59 2006
@@ -22,6 +22,9 @@
                 continue;
             }
             var field = form[oMinLength[x][0]];
+            if (!jcv_isFieldPresent(field)) {
+              continue;
+            }
 
             if ((field.type == 'hidden' ||
                 field.type == 'text' ||

Modified: jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateRequired.js
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateRequired.js?rev=367249&r1=367248&r2=367249&view=diff
==============================================================================
--- jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateRequired.js
(original)
+++ jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateRequired.js
Mon Jan  9 00:50:59 2006
@@ -21,7 +21,7 @@
             }
             var field = form[oRequired[x][0]];
 
-            if (field == null) {
+            if (!jcv_isFieldPresent(field)) {
                 fields[i++] = oRequired[x][1];
                 isValid=false;
             } else if ((field.type == 'hidden' ||

Modified: jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateShort.js
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateShort.js?rev=367249&r1=367248&r2=367249&view=diff
==============================================================================
--- jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateShort.js
(original)
+++ jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateShort.js
Mon Jan  9 00:50:59 2006
@@ -19,6 +19,9 @@
                 continue;
             }
             var field = form[oShort[x][0]];
+            if (!jcv_isFieldPresent(field)) {
+              continue;
+            }
 
             if ((field.type == 'hidden' ||
                 field.type == 'text' ||

Modified: jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateUtilities.js
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateUtilities.js?rev=367249&r1=367248&r2=367249&view=diff
==============================================================================
--- jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateUtilities.js
(original)
+++ jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript/validateUtilities.js
Mon Jan  9 00:50:59 2006
@@ -82,6 +82,14 @@
   }
 
   /**
+   * Checks whether the field is present on the form.
+   * @param field The form field.
+   */
+  function jcv_isFieldPresent(field) {
+      return !(field == null || field == undefined);
+  }
+
+  /**
    * Check a value only contains valid numeric digits
    * @param argvalue The value to check.
    */

Modified: jakarta/commons/proper/validator/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/validator/trunk/xdocs/changes.xml?rev=367249&r1=367248&r2=367249&view=diff
==============================================================================
--- jakarta/commons/proper/validator/trunk/xdocs/changes.xml (original)
+++ jakarta/commons/proper/validator/trunk/xdocs/changes.xml Mon Jan  9 00:50:59 2006
@@ -39,6 +39,12 @@
   <body>
 
     <release version="1.2.1 (alpha)" date="in SVN">
+      <action dev="niallp" type="fix" issue="14471">
+         Change JavaScript validators so that they don't fail when the
+         field is not present on the form.
+        <dueto name="Andrew Berridge"/>
+        <dueto name="Paul Benedict"/>
+      </action>
       <action dev="niallp" type="fix" issue="37962" due-to="Alan Olmanson">
          Fix min/max length validation for different line endings.
       </action>



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


Mime
View raw message