Bug #15034
closed
Radio button validation does not work if there is only one radio button
Added by old_gunthersc about 19 years ago.
Updated over 18 years ago.
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
Added an unified diff patch for the issue. The issue is also present in 3.8.0.
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
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.
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
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.
Also available in: Atom
PDF