I'm creating a form from various complex controls that I have built as Backbone views. Understandably I want to reliably link the labels to the <input>
elements, which I am doing with the normal for
attribute.
However, sometimes I need to use the same control multiple times. I am using data attributes to drive the form, so I do not need the id
attribute for my own use, and can use classes to identify each control.
Therefore, I am considering whether it makes sense to generate random ids, just to link the <label>
and <input>
together? This seems a really bad idea, but I am unsure there is a better one?
I can't just put the <input>
inside the <label>
, as they have to be separate from each other.