Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for customization of validation messages' placement #8

Open
luiz opened this issue Oct 20, 2016 · 0 comments
Open

Support for customization of validation messages' placement #8

luiz opened this issue Oct 20, 2016 · 0 comments

Comments

@luiz
Copy link
Contributor

luiz commented Oct 20, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant