Open In App

What is the use of is-valid & is-invalid Classes in Bootstrap ?

Last Updated : 19 Feb, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

The .is-valid and .is-invalid classes in Bootstrap are used to style form inputs based on their validation status. .is-valid is applied to inputs that have passed validation, while .is-invalid is applied to inputs that have failed validation. These classes provide visual feedback to users, indicating whether their input is accepted or requires correction.

Syntax:

<input type="text" class="form-control is-valid" id="validationValid01" value="Input is valid" required>
<input type="text" class="form-control is-invalid" id="validationInvalid01" value="Input is invalid" required>

Explanation: When applied to form inputs, the .is-valid the class adds styling to indicate that the input has passed validation, typically displaying a green border or background. Conversely, the .is-invalid class adds styling to indicate that the input has failed validation, often displaying a red border or background. These classes help users easily identify the status of their input and take appropriate action to correct any errors.

Features:

  • Provides visual feedback to users regarding the validation status of form inputs.
  • .is-valid class indicates that the input has passed validation, while .is-invalid the class indicates validation failure.
  • Easily integrates with Bootstrap’s form components, ensuring consistent styling across different input types.
  • Facilitates accessibility by improving the usability of forms, especially for users with disabilities or impairments.

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads