commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nia...@apache.org
Subject svn commit: r330243 - in /jakarta/commons/proper/validator/trunk/src/javascript/org/apache/commons/validator/javascript: validateByte.js validateInteger.js validateShort.js validateUtilities.js
Date Wed, 02 Nov 2005 12:26:13 GMT
Author: niallp
Date: Wed Nov  2 04:26:02 2005
New Revision: 330243

URL: http://svn.apache.org/viewcvs?rev=330243&view=rev
Log:
Bug 37300 - Add new isDecimalDigits() function and change Byte, Short and Integer validations
to use it rather than the isAllDigits() function.

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/validateInteger.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

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=330243&r1=330242&r2=330243&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
Wed Nov  2 04:26:02 2005
@@ -36,7 +36,7 @@
                 }
 
                 if (value.length > 0) {
-                    if (!isAllDigits(value)) {
+                    if (!isDecimalDigits(value)) {
                         bValid = false;
                         if (i == 0) {
                             focusField = field;

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=330243&r1=330242&r2=330243&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
Wed Nov  2 04:26:02 2005
@@ -36,7 +36,7 @@
 
                 if (value.length > 0) {
 
-                    if (!isAllDigits(value)) {
+                    if (!isDecimalDigits(value)) {
                         bValid = false;
                         if (i == 0) {
                             focusField = field;

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=330243&r1=330242&r2=330243&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
Wed Nov  2 04:26:02 2005
@@ -36,7 +36,7 @@
                 }
 
                 if (value.length > 0) {
-                    if (!isAllDigits(value)) {
+                    if (!isDecimalDigits(value)) {
                         bValid = false;
                         if (i == 0) {
                             focusField = field;

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=330243&r1=330242&r2=330243&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
Wed Nov  2 04:26:02 2005
@@ -59,3 +59,22 @@
       }
       return true;
   }
+
+  /**
+   * Check a value only contains valid decimal digits
+   * @param argvalue The value to check.
+   */
+  function isDecimalDigits(argvalue) {
+      argvalue = argvalue.toString();
+      var validChars = "0123456789";
+
+      var startFrom = 0;
+      if (argvalue.charAt(0) == "-") {
+          startFrom = 1;
+      }
+
+      for (var n = startFrom; n < argvalue.length; n++) {
+          if (validChars.indexOf(argvalue.substring(n, n+1)) == -1) return false;
+      }
+      return true;
+  }



---------------------------------------------------------------------
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