Bug #15034
closedRadio button validation does not work if there is only one radio button
0%
Description
validateForm() will not correctly validate radio buttons if there is only one radio button in a group. This is because fObj.length (t3lib/jsfunc.validateform.js line 87) is undefined in this case, and therefore the validation loop is never entered and "value" remains undefined.
This is easily fixed by changing the code as seen in the file attached.
(issue imported from #M1578)
Files
Updated by old_gunthersc about 19 years ago
Added an unified diff patch for the issue. The issue is also present in 3.8.0.
Updated by Sebastian Kurfuerst about 19 years ago
Hm, in which case do you need only one radio button? This doesn't make any sense to me, as the user cannot deselect it anymore. Isn't it better to use checkboxes instead?
Greets, Sebastian
Updated by old_gunthersc about 19 years ago
Hi Sebastian: this is not a case of needing only one radio button, but it happened in an automated ticketing form that creates a number of radio buttons depending dynamically on what kinds of tickets are available.
Usually there are several kinds of tickets, but we did run into this bug when there was only one kind of ticket -- and therefore only one radio button -- available.
Updated by Sebastian Kurfuerst about 19 years ago
Hi,
I think it is interesting that length is not 1 if there is only one radio button defined, but not defined... Is this normal JS behavior, do you know this?
Greets, Sebastian
Updated by old_gunthersc about 19 years ago
Apparently yes, from my tests to figure out the source of this bug. Basically, if you only have one button, it's not an array of buttons and therefore has no length.