You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by bu...@apache.org on 2003/03/10 17:27:07 UTC
DO NOT REPLY [Bug 17835] New: -
The javascript code to validate integers does not display an alert box if the number being validated has invalid digits. (i.e. floating point numbers)
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17835>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17835
The javascript code to validate integers does not display an alert box if the number being validated has invalid digits. (i.e. floating point numbers)
Summary: The javascript code to validate integers does not
display an alert box if the number being validated has
invalid digits. (i.e. floating point numbers)
Product: Struts
Version: Unknown
Platform: PC
OS/Version: Windows NT/2K
Status: NEW
Severity: Normal
Priority: Other
Component: Validator Framework
AssignedTo: struts-dev@jakarta.apache.org
ReportedBy: chad.flentje@firepond.com
The javascript code to validate integers does not display an alert box if the
number being validated has invalid digits. (i.e. floating point numbers)
Solution to correct the problem in file validator-rules.xml
1. If the call to function isAllDigits fails, then variables focusField and
fields should be set properly so an alert message can be presented to the user.
Example
function validateInteger(form) {
var bValid = true;
var focusField = null;
var i = 0;
var fields = new Array();
oInteger = new IntegerValidations();
for (x in oInteger) {
var field = form[oInteger[x][0]];
if (field.type == 'text' ||
field.type == 'textarea' ||
field.type == 'select-one' ||
field.type == 'radio') {
var value = '';
// get field's value
if (field.type == "select-one")
{
var si =
field.selectedIndex;
if (si >= 0) {
value =
field.options[si].value;
}
} else {
value = field.value;
}
if (value.length > 0) {
if (!isAllDigits(value)) {
if (i == 0) {
focusField = field;
}
fields[i++] = oInteger[x][1];
bValid = false;
} else {
var iValue = parseInt(value);
if (isNaN(iValue) || !(iValue >= -
2147483648 && iValue <= 2147483647)) {
if (i == 0) {
focusField = field;
}
fields[i++] = oInteger[x][1];
bValid = false;
}
}
}
}
}
if (fields.length > 0) {
focusField.focus();
alert(fields.join('\n'));
}
return bValid;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org