1
0
mirror of https://github.com/tabler/tabler.git synced 2025-12-22 01:44:25 +04:00
Files
tabler/docs/ui/forms/form-validation.md

2.5 KiB

title, summary, description, layout
title summary description layout
Validation states To inform users whether the entered value is correct or not, use either of the validation states. Thanks to that, users will immediately know which form elements they need to correct and, if the state displays as invalid, why the value is incorrect. Indicate valid or invalid inputs. default

Validation states

To inform users whether the entered value is correct or not, use either of the validation states. Thanks to that, users will immediately know which form elements they need to correct and, if the state displays as invalid, why the value is incorrect.

To apply the validation state to the form control, use the .is-valid and .is-invalid classes.

<input type="text" class="form-control is-valid" placeholder="Valid State..." />
<input type="text" class="form-control is-invalid" placeholder="Invalid State..." />

Validation feedback

To provide users with additional information about the validation state, you can use the .valid-feedback and .invalid-feedback classes.

<input type="text" class="form-control is-valid" placeholder="Valid State..." />
<div class="valid-feedback">Looks good!</div>

This is how it works in the example below:

<div>
  <label class="form-label required">City</label>
  <input type="text" class="form-control is-invalid" required>
  <div class="invalid-feedback">
    Please provide a valid city.
  </div>
</div>

You can also use the .valid-feedback to provide users with positive feedback.

<div>
  <label class="form-label required">City</label>
  <input type="text" class="form-control is-valid" value="Warsaw">
  <div class="valid-feedback">
    Looks good!
  </div>
</div>

Subtle validation states

If you prefer a more subtle manner of informing users of the input control validation state, you can use tick and cross symbols and resign from colored control frames and the validation feedback.

To do this, use the .is-valid-lite and .is-invalid-lite classes.

<input type="text" class="form-control is-valid is-valid-lite" placeholder="Valid State..." />

Look how it works in the example below:

<input type="text" class="form-control is-valid is-valid-lite" placeholder="Valid State..." />
<input type="text" class="form-control is-invalid is-invalid-lite" placeholder="Invalid State..." />