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=16259>.
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=16259

javascript validation fails for select-one 

           Summary: javascript validation fails for select-one
           Product: Struts
           Version: 1.1 Beta 3
          Platform: All
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Validator Framework
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


The validator javascript method fails when a select-one doesn't have selected 
option. It happens because the object's selectedIndex is (-1) - when nothing is 
selected and the value read by the index of (-1) causes a javascript error:

if (field.type == "select-one") {
  var si = field.selectedIndex;
  value = field.options[si].value; //error if si == -1
}

the following code prevents this error:

if (field.type == "select-one") {
  var si = field.selectedIndex;
  if (si == -1) {
    value = '';
  } else {
    value = field.options[si].value;
  }
}

The following validation methods are affected: required, byte, short, integer, 
float.

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to