Skip to content

Support for customization of validation messages' placement #8

Description

@luiz

Currently, it is assumed that inputs being validated are placed inside a <label> element, and validation messages are appended to this element, thus resulting in the following HTML structure after a validation error:

<label class='validation error'>
  <input required>
  <span class='validation-message'>Please fill this field</span>
</label>

However, this is not always the case. Sometimes, the HTML structure is more complex or the validation message should be placed somewhere else. Therefore, it should be possible to customize validation messages' placement on a per-input basis.

A first version might support customizing the ancestor in which the message will be appended. For instance:

<label>
  <div class='tagged-input'>
    <span class='tag'>some tag</span>
    <span class='tag'>other tag</span>
    <input data-validation-append='label'>
  </div>
</label>

In the previous example, we would be telling the library that we want the messages to be appended to the closest ancestor that matches the label selector.

Future versions may extend this configuration, allowing for specification of any element related to the input being validated, not only ancestors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions