Skip to main content

Validation



Development

This section details the technical implementation of validation in form components, utilizing component attributes along with corresponding CSS classes to represent various validation states.

Validation text

  • helperText (optional): Text displayed below the field component to provide additional information.
  • infoText (optional): Informational text for the field component.
  • warningText (optional): Warning text for the field component.
  • invalidText (optional): Error text for the field component.
  • validText (optional): Valid text for the field component.
  • showTextAsTooltip (optional): Determines whether to display helper, info, warning, error, and valid text as tooltips.

Validation states

To change the validation representation, you have to apply the corresponding classes to the component.

  • ix-valid: To show component as valid (Priority 1)
  • ix-info: To show component as info (Priority 2)
  • ix-warning: To show component as warning (Priority 3)
  • ix-invalid: To show component as invalid (Priority 4)

These classes have different priority levels, which determining in which order the styling is applied to the component. (1 is the lowest priority and 3 the highest)

Example

<ix-select class="ix-invalid ix-info"></ix-select>

Above example will result in displaying the component as invalid, because invalid has a higher priority than info.

💡You are using Angular?

When using Angular in combination with reactive forms, it is not necessary to manually apply the CSS classes .ix-invalid and .ix-valid. This will be done automatically through value accessors.

Suppress internal validation

To suppress the internal validation of a component, you have to provide the novalidate attribute to the form element.

<form novalidate>
<!-- form content -->
</form>

Example

💡Important

Please note that using the required attribute in an Angular application could result in unfavourabe behaviour displaying the field as invalid even if there was no user interaction yet. To avoid that it is suggested not to add the required attribute, but implement a custom validator for required fields instead (see name and last-name in the following code).