We have developed a set of Field objects tha create sets of [label-input field] sets of different types,
textboxes, radio buttons, checkboxes. The source Fields.js contains the code for the library
Both sets of controls are drawn through the same code. The HTML generated is exactly the same, the only difference is the className of the enclosing fieldset which completely changes the layout.
The base object in the library inherits from Element while the rest inherit from this base.
This is common practice for all newer YUI widgets and is recomended for all user widgets as well.
The code also shows several other common practices which were extracted from actual YUI components.
Both textboxes have validators assigned, the first will only take numbers, the second only letter and numbers.