Form validation styles help users see if their input is correct or needs fixing. This makes forms easier and faster to use.
Form validation styles in Bootsrap
<input class="form-control is-valid" /> <input class="form-control is-invalid" />
Use is-valid class to show valid input with green border and icon.
Use is-invalid class to show invalid input with red border and icon.
<input type="text" class="form-control is-valid" placeholder="Valid input">
<input type="email" class="form-control is-invalid" placeholder="Invalid email">
<div class="valid-feedback">Looks good!</div>
<div class="invalid-feedback">Please enter a valid value.</div>
This example shows a form with two inputs. The username input is marked valid with a green border and message. The email input is marked invalid with a red border and error message. This helps users quickly see which fields need attention.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>Bootstrap Form Validation Styles</title> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet" /> </head> <body> <main class="container mt-5"> <h1>Form Validation Styles Example</h1> <form> <div class="mb-3"> <label for="username" class="form-label">Username (valid)</label> <input type="text" class="form-control is-valid" id="username" value="user123" aria-describedby="usernameFeedback" /> <div id="usernameFeedback" class="valid-feedback"> Looks good! </div> </div> <div class="mb-3"> <label for="email" class="form-label">Email (invalid)</label> <input type="email" class="form-control is-invalid" id="email" aria-describedby="emailFeedback" placeholder="name@example.com" /> <div id="emailFeedback" class="invalid-feedback"> Please enter a valid email address. </div> </div> <button type="submit" class="btn btn-primary">Submit</button> </form> </main> </body> </html>
Always use aria-describedby to link inputs with feedback messages for screen readers.
Validation styles only change appearance; you still need JavaScript or server checks for real validation.
Use these styles to improve user experience by giving clear visual feedback.
Use is-valid and is-invalid classes to show input status.
Pair inputs with valid-feedback or invalid-feedback messages for clarity.
These styles help users fix mistakes quickly and feel confident about their input.