You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by tu...@apache.org on 2003/01/20 05:32:24 UTC
cvs commit: jakarta-struts/conf/share validator-rules.xml
turner 2003/01/19 20:32:24
Modified: conf/share validator-rules.xml
Log:
Make validateInteger work for cases where the input string ends in a non-numeric (fixes bug 15913)
Please bang on this a bit, Javascript isn't my forte and you can't unit test it. I tried for all the
cases I could think of, and it seemed to work fine.
James
Revision Changes Path
1.21 +18 -0 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.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- validator-rules.xml 9 Dec 2002 05:23:44 -0000 1.20
+++ validator-rules.xml 20 Jan 2003 04:32:24 -0000 1.21
@@ -404,6 +404,9 @@
if (value.length > 0) {
+ if (!isAllDigits(value)) {
+ bValid = false;
+ } else {
var iValue = parseInt(value);
if (isNaN(iValue) || !(iValue >= -2147483648 && iValue <= 2147483647)) {
if (i == 0) {
@@ -412,6 +415,7 @@
fields[i++] = oInteger[x][1];
bValid = false;
}
+ }
}
}
}
@@ -420,6 +424,20 @@
alert(fields.join('\n'));
}
return bValid;
+ }
+
+ function isAllDigits(argvalue) {
+ argvalue = argvalue.toString();
+ var validchars = "012345679";
+ var startFrom = 0;
+ if (argvalue.substring(0, 2) == "0x") {
+ validchars = "012345679abcdefABCDEF";
+ startFrom = 2;
+ }
+ for (var n = 0; n < argvalue.length; n++) {
+ if (validChars.indexOf(argvalue.substring(n, n+1)) == -1) return false;
+ }
+ return true;
}]]>
</javascript>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>