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=18373>. 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=18373 validateInteger javascript doesn't display warning message Summary: validateInteger javascript doesn't display warning message Product: Struts Version: 1.1 RC1 Platform: PC OS/Version: Windows XP Status: NEW Severity: Normal Priority: Other Component: Validator Framework AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] validateInteger did not display a warning message when I typed all characters in a validated field. When I clicked submit the form did not submit, and there was no error message. It also did not work properly for negative numbers. It did work for range validation. The reason for this bug is that two javascript methods have bugs. I fixed the methods and pasted the code below. As an aside, I think that you should reconsider the wisdom of incorporating HEX and OCTAL validation in this method. I believe that the average Struts user would not expect this behavior. A separate validateHex and validateOctal method would be a better solution. If you really want a catch-all method, maybe validateAllIntegers would give users a clue as to what is going on. The 99% use case will be standard decimal integers. The validation framework is a tremendous timesaver. Thanks for the good work. 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)) { bValid = false; // BEGIN ERROR MESSAGE FIX focusField = field; fields[i++] = oInteger[x][1]; // END ERROR MESSAGE FIX } 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; } function isAllDigits(argvalue) { argvalue = argvalue.toString(); var validChars = "0123456789"; var startFrom = 0; if (argvalue.substring(0, 2) == "0x") { validChars = "0123456789abcdefABCDEF"; startFrom = 2; } else if (argvalue.charAt(0) == "0") { validChars = "01234567"; startFrom = 1; } // BEGIN NEGATIVE NUMBER FIX else if (argvalue.charAt(0) == "-") { validChars = "0123456789"; startFrom = 1; alert("first char dash"); } // END NEGATIVE NUMBER FIX for (var n = startFrom; n < argvalue.length; n++) { if (validChars.indexOf(argvalue.substring(n, n+1)) == -1) return false; } alert("isAllDigits returning true"); return true; } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]