PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » HTML » HTML_QuickForm » Bug #3035

JS validation bug

Details

Submitted2004-12-27 14:10 UTC
Fromilia at manual dot ru
Assignedavb
StatusClosed
PackageHTML_QuickForm
PHP Version5.0.3
OSFreeBSD 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.