Home » HTML » HTML_QuickForm » Bug #3035
JS validation bug
Details
| Submitted | 2004-12-27 14:10 UTC |
|---|---|
| From | ilia at manual dot ru |
| Assigned | avb |
| Status | Closed |
| Package | HTML_QuickForm |
| PHP Version | 5.0.3 |
| OS | FreeBSD 5.3 |
| Roadmaps | (Not assigned) |
Comments
[2004-12-27 14:10 UTC] ilia at manual dot ru
Description:
------------
selects with size>1 have no chosen element so JS validation code fails with error.
Solution:
RuleRegistry.php about line 280
$value = " value{$jsIndex} = frm.elements['{$elementName}'].options[frm.elements['{$elementName}'].selectedIndex].value;\n";
change to
$value = " value{$jsIndex} = frm.elements['{$elementName}'].selectedIndex != -1 ? frm.elements['{$elementName}'].options[frm.elements['{$elementName}'].selectedIndex].value : '';\n";
[2005-03-14 13:06 UTC] bigtree-dontspamme at 29a dot nl
Actually, the bug appears if a 'select' element with 'multiple' set to false does not have any option elements. In that case, selectedIndex is -1.
The fix ilia at manual dot ru suggested works for me.