VOOZH about

URL: https://www.geeksforgeeks.org/bootstrap/bootstrap-5-validation/

⇱ Bootstrap 5 Validation - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Bootstrap 5 Validation

Last Updated : 23 Jul, 2025

Bootstrap 5 Validation refers to the process of enhancing form input accuracy in web development. It utilizes HTML5 validation features, providing feedback to users regarding input correctness. This feature supports customization with custom styles and JavaScript for improved user experience.

Bootstrap 5 Validation:

TermDescription
Custom stylesAdd custom Bootstrap form validation messages by adding the novalidate boolean attribute to <form> an element. Disables default browser feedback tooltips.
Browser defaultsNo pre-defined class for feedback styles; cannot be styled with CSS. Feedback text can be customized via JavaScript.
Server-sideIndicate invalid and valid form fields with .is-invalid and .is-valid. Use .invalid-feedback and .valid-feedback for feedback messages.
Supported elements.form-control for <input> and <textarea>, .form-select for <select>, .form-check for checkboxes and radios.
TooltipsValidation tooltips provide interactive textual hints about form submission requirements.
SASSBootstrap 5 provides various SASS variables to validate form fields, ensuring accurate user-provided details.

Example 1: In this example, a form is created where the "Student Name", "Roll no" and "Mobile Number" of the student needs to be submitted and by default this form will get validated by the browser using the required attribute.

Output:

Example 2: In this example, we create Bootstrap form includes fields for name, email, password, gender, date of birth, and address. JavaScript validates password match, email format, gender selection, and address presence before submission.

Output:

Comment
Article Tags:

Explore