commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nia...@apache.org
Subject svn commit: r367050 - in /jakarta/commons/proper/validator/trunk: src/javascript/org/apache/commons/validator/javascript/ xdocs/
Date Sun, 08 Jan 2006 17:00:12 GMT
Author: niallp
Date: Sun Jan  8 08:59:54 2006
New Revision: 367050

URL: http://svn.apache.org/viewcvs?rev=367050&view=rev
Log:
Fix for Bugs 21043/32476 - Don't set focus on hidden or CSS hidden fields in JavaScript validation
- thanks to Matt Bathje and 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=367050&r1=367049&r2=367050&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
Sun Jan  8 08:59:54 2006
@@ -59,8 +59,7 @@
             }
         }
         if (fields.length > 0) {
-           focusField.focus();
-           alert(fields.join('\n'));
+           jcv_handleErrors(fields, focusField);
         }
         return bValid;
     }

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=367050&r1=367049&r2=367050&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
Sun Jan  8 08:59:54 2006
@@ -29,8 +29,7 @@
             }
         }
         if (fields.length > 0) {
-            focusField.focus();
-            alert(fields.join('\n'));
+            jcv_handleErrors(fields, focusField);
         }
         return bValid;
     }

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=367050&r1=367049&r2=367050&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
Sun Jan  8 08:59:54 2006
@@ -159,8 +159,7 @@
           }
        }
        if (fields.length > 0) {
-          focusField.focus();
-          alert(fields.join('\n'));
+          jcv_handleErrors(fields, focusField);
        }
        return bValid;
     }

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=367050&r1=367049&r2=367050&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
Sun Jan  8 08:59:54 2006
@@ -31,8 +31,7 @@
             }
         }
         if (fields.length > 0) {
-            focusField.focus();
-            alert(fields.join('\n'));
+            jcv_handleErrors(fields, focusField);
         }
         return bValid;
     }

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=367050&r1=367049&r2=367050&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
Sun Jan  8 08:59:54 2006
@@ -66,8 +66,7 @@
             }
         }
         if (fields.length > 0) {
-           focusField.focus();
-           alert(fields.join('\n'));
+           jcv_handleErrors(fields, focusField);
         }
         return bValid;
     }

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=367050&r1=367049&r2=367050&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
Sun Jan  8 08:59:54 2006
@@ -34,8 +34,7 @@
             }
         }
         if (fields.length > 0) {
-            focusField.focus();
-            alert(fields.join('\n'));
+            jcv_handleErrors(fields, focusField);
         }
         return isValid;
     }

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=367050&r1=367049&r2=367050&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
Sun Jan  8 08:59:54 2006
@@ -43,8 +43,7 @@
             }
         }
         if (fields.length > 0) {
-            focusField.focus();
-            alert(fields.join('\n'));
+            jcv_handleErrors(fields, focusField);
         }
         return isValid;
     }

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=367050&r1=367049&r2=367050&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
Sun Jan  8 08:59:54 2006
@@ -57,8 +57,7 @@
             }
         }
         if (fields.length > 0) {
-           focusField.focus();
-           alert(fields.join('\n'));
+           jcv_handleErrors(fields, focusField);
         }
         return bValid;
     }

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=367050&r1=367049&r2=367050&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
Sun Jan  8 08:59:54 2006
@@ -34,8 +34,7 @@
         }
 
         if (fields.length > 0) {
-           focusField.focus();
-           alert(fields.join('\n'));
+           jcv_handleErrors(fields, focusField);
         }
         return isValid;
     }

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=367050&r1=367049&r2=367050&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
Sun Jan  8 08:59:54 2006
@@ -36,8 +36,7 @@
             }
         }
         if (fields.length > 0) {
-           focusField.focus();
-           alert(fields.join('\n'));
+           jcv_handleErrors(fields, focusField);
         }
         return isValid;
     }

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=367050&r1=367049&r2=367050&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
Sun Jan  8 08:59:54 2006
@@ -37,8 +37,7 @@
             }
         }
         if (fields.length > 0) {
-           focusField.focus();
-           alert(fields.join('\n'));
+           jcv_handleErrors(fields, focusField);
         }
         return isValid;
     }

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=367050&r1=367049&r2=367050&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
Sun Jan  8 08:59:54 2006
@@ -89,10 +89,7 @@
             }   
         }
         if (fields.length > 0) {
-           if (focusField != null) {
-               focusField.focus();
-           }     
-           alert(fields.join('\n'));
+           jcv_handleErrors(fields, focusField);
         }
         return isValid;
     }

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=367050&r1=367049&r2=367050&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
Sun Jan  8 08:59:54 2006
@@ -58,8 +58,7 @@
             }
         }
         if (fields.length > 0) {
-           focusField.focus();
-           alert(fields.join('\n'));
+           jcv_handleErrors(fields, focusField);
         }
         return bValid;
     }

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=367050&r1=367049&r2=367050&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
Sun Jan  8 08:59:54 2006
@@ -41,6 +41,30 @@
   }  
 
   /**
+   * Handle error messages.
+   * @param messages Array of error messages.
+   * @param focusField Field to set focus on.
+   */
+  function jcv_handleErrors(messages, focusField) {
+      if (focusField && focusField != null) {
+          var doFocus = true;
+          if (focusField.disabled || focusField.type == 'hidden') {
+              doFocus = false;
+          }
+          if (doFocus && 
+              focusField.style && 
+              focusField.style.visibility &&
+              focusField.style.visibility == 'hidden') {
+              doFocus = false;
+          }
+          if (doFocus) {
+              focusField.focus();
+          }
+      }
+      alert(messages.join('\n'));
+  }
+
+  /**
    * 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=367050&r1=367049&r2=367050&view=diff
==============================================================================
--- jakarta/commons/proper/validator/trunk/xdocs/changes.xml (original)
+++ jakarta/commons/proper/validator/trunk/xdocs/changes.xml Sun Jan  8 08:59:54 2006
@@ -39,6 +39,14 @@
   <body>
 
     <release version="1.2.1 (alpha)" date="in SVN">
+      <action dev="niallp" type="fix">
+         Re-factor JavaScript error handling into a common method and only
+         set focus on fields which are not 'hidden' type or hidden by CSS.
+        <fixes issue="21043"/> 
+        <fixes issue="32476"/>
+        <dueto name="Matt Bathje"/>
+        <dueto name="Paul Benedict"/>
+      </action>
       <action dev="niallp" type="fix" issue="35926">
          Reverse change for to Credit Card Validator for visa card blue in France.
       </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