This changes the form validation styles to only apply to elements with an explicit required
attribute. While working on a new form example for #24898, it caught me off guard that we were saying optional inputs were valid
when in fact there's nothing to actually validate. This change ensures that only required inputs, selects, textareas, and custom form controls are validated and effectively treats all non-required
form controls as opt-in for form validation styles.
Here's the before and after to show you what I mean. Note how the second address line and two checkboxes shouldn't be green as it implies we performed validation on value
s that don't exist.
Before | After |
---|---|