Bootstrap 5 form validation provides visual feedback for user inputs. This page covers 4 validation patterns — browser validation, custom messages, real-time and inline errors — each with working JavaScript.
Quick Setup
Form validation requires Bootstrap 5 CSS and JS:
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
Key Classes Reference
| Class | What It Does |
|---|---|
.was-validated | Triggers validation styles on entire form |
.is-valid | Green valid state on individual input |
.is-invalid | Red invalid state on individual input |
.valid-feedback | Green success message below input |
.invalid-feedback | Red error message below input |
.valid-tooltip | Green tooltip-style success message |
.invalid-tooltip | Red tooltip-style error message |
novalidate | Disables browser default validation UI |
required | HTML5 required field attribute |
1. Bootstrap 5 Browser Validation
Built-in HTML5 browser validation styled with Bootstrap. Add novalidate to the form and was-validated on submit.
2. Bootstrap 5 Custom Validation Messages
Custom error messages using is-invalid and invalid-feedback classes. Full control over when errors show.
3. Bootstrap 5 Real-Time Validation
Validate fields as the user types using input event listeners. Immediate feedback on each field.
4. Bootstrap 5 Inline Error Messages
Error messages displayed inline below each field with icons for a clear, accessible validation UI.
Frequently Asked Questions
Need a Full Bootstrap 5 Admin Dashboard?
Get a complete Angular 21 + Bootstrap 5 dashboard with 50+ components — built by the same team behind BootstrapPlanet.
Browse Templates →Use code FIRST30 for 30% off your first purchase.