Bootstrap 5 FormsLesson 40Free preview
BS5 Form Validation
This lesson is part of Bootstrap · All levels
Summary
Bootstrap form validation works by adding the required attribute to the control and then displaying a successful or failed style based on the .was-validated class on <form>. Bootstrap also provides inbuilt feedback in the form of .valid-feedback and .invalid-feedback that appears according to the filling status. Alternatively, manually mark the control with .is-valid or .is-invalid via JavaScript.
Key points
- Attributes required, email types, and patterns support browser-based validation.
- The class on the list shows success and failure styles. (<form>) (.was-validated)
- .valid-feedback appears when the control is declared valid.
- .invalid-feedback appears when the control is declared invalid.
- JavaScript can mark controls with .is-valid or .is-invalid.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.