mc0de
mC0de / Bootstrap Elements / Lesson 07 of 07

Bootstrap Form Design

Turn ordinary forms into polished, responsive experiences. Master Bootstrap inputs, labels, select menus, checkboxes, validation, and professional form layouts.

Beginner Friendly Bootstrap 5.3 Form Validation Final Challenge
forms.html
<input type="email"
  class="form-control"
  placeholder="you@example.com">
Your name
you@example.com
Bootstrap Elements ▾
Register Now →
01 / Getting Started

What Is Bootstrap Form Design?

Forms allow users to enter and submit information. You’ll find them in registration pages, contact forms, login screens, surveys, and checkout experiences.

Bootstrap makes form controls visually consistent and responsive without requiring you to write all the CSS yourself.

Enter your name
you@example.com
Register Now →
Remember: A good form isn’t just attractive. It should also be understandable, accessible, and easy to complete.
02 / Text Inputs

Create Your First Bootstrap Input

Bootstrap’s form-control class styles text inputs, email fields, passwords, and other common controls.

<div class="mb-3">
  <label for="studentName" class="form-label">
    Full Name
  </label>
  <input type="text"
    class="form-control"
    id="studentName"
    name="studentName"
    placeholder="Enter your name"
    required>
</div>
form-controlApplies Bootstrap styling to text-based controls.
form-labelStyles the descriptive label above a field.
mb-3Adds bottom margin to separate fields.
requiredMarks a field as mandatory for browser validation.

The label’s for value should match the input’s id. This helps users understand which label belongs to which field.

03 / Input Types

Choose the Right Input Type

Different input types help browsers provide suitable keyboards and validation behavior.

<input type="text" class="form-control">
<input type="email" class="form-control">
<input type="password" class="form-control">
<input type="number" class="form-control">
<input type="date" class="form-control">
Tip: Use type="email" for email addresses. Browsers can then check the basic email format before allowing submission.
04 / Select Menus

Create a Dropdown Selection

Use form-select to style a native HTML select menu.

<label for="course" class="form-label">
  Choose a Course
</label>

<select id="course" name="course"
  class="form-select" required>
  <option value="" selected disabled>
    Select a course
  </option>
  <option value="html">HTML & CSS</option>
  <option value="bootstrap">Bootstrap</option>
  <option value="javascript">JavaScript</option>
</select>

The empty first option encourages users to make a deliberate selection rather than accepting an accidental default.

05 / Textareas

Collect Longer Responses

Use a <textarea> when users need to enter multiple lines of text, such as comments or questions.

<label for="message" class="form-label">
  Additional Comments
</label>

<textarea id="message" name="message"
  class="form-control"
  rows="4"
  placeholder="Write your message..."></textarea>

The rows attribute controls the initial visible height of the text area.

06 / Checkboxes and Radio Buttons

Offer Clear Choices

Use checkboxes for independent yes/no choices, and radio buttons when users must choose one option from a group.

<div class="form-check">
  <input class="form-check-input"
    type="checkbox" id="updates">
  <label class="form-check-label" for="updates">
    Send me course updates
  </label>
</div>

<div class="form-check">
  <input class="form-check-input"
    type="radio" name="schedule"
    id="day" value="day">
  <label class="form-check-label" for="day">
    Day Classes
  </label>
</div>

<div class="form-check">
  <input class="form-check-input"
    type="radio" name="schedule"
    id="evening" value="evening">
  <label class="form-check-label" for="evening">
    Evening Classes
  </label>
</div>
Important: Radio buttons sharing the same name belong to one group, allowing only one selection at a time.
07 / Responsive Layouts

Arrange Form Fields in Columns

Bootstrap’s grid system lets you display fields side by side on larger screens while stacking them on mobile.

<div class="row g-3">
  <div class="col-12 col-md-6">
    <label for="first" class="form-label">
      First Name
    </label>
    <input id="first" class="form-control">
  </div>

  <div class="col-12 col-md-6">
    <label for="last" class="form-label">
      Last Name
    </label>
    <input id="last" class="form-control">
  </div>
</div>

col-12 uses the full width on small screens, while col-md-6 uses half the row at the medium breakpoint and above.

08 / Validation

Help Users Correct Mistakes

Bootstrap provides is-valid, is-invalid, valid-feedback, and invalid-feedback classes for visual validation messages.

<div class="mb-3">
  <label for="email" class="form-label">
    Email Address
  </label>
  <input type="email"
    class="form-control"
    id="email"
    required>
  <div class="invalid-feedback">
    Please enter a valid email address.
  </div>
</div>

For browser-assisted Bootstrap validation, add needs-validation to the form and apply was-validated when the user attempts to submit.

const form = document.querySelector('form');

form.addEventListener('submit', event => {
  if (!form.checkValidity()) {
    event.preventDefault();
  }
  form.classList.add('was-validated');
});
Security reminder: Browser validation improves usability, but real applications must also validate submitted data on the server. Our Sandbox is a demonstration, not a production registration service.
09 / Buttons and Submission

Finish Your Form with a Submit Button

A button with type="submit" triggers the form’s submission process. Bootstrap’s btn and btn-primary classes provide its appearance.

<button type="submit" class="btn btn-primary">
  Register Now
</button>

In the Sandbox, successful submission displays a confirmation inside the preview. It does not send the information to a server.

Final Challenge / Practice Time

🚀 mC0de Challenge

Build a Course Registration Form

You’re creating a registration form for an online coding academy. Students should be able to enter their information, choose a course, and receive feedback when required information is missing.

Your mission: Complete all six tasks in the Sandbox below.

Check off your tasks as you complete them, then compare your work with the sample solution.

Interactive Coding Workspace

mC0de Bootstrap Sandbox

Edit your registration form, run the code, and test the validation in the live preview.

HTML Input / forms.html
Live Result / Bootstrap 5.3
Ready to code. Test your form using the Register Now button.
Final Lesson Recap

✓ What You've Learned

  • form-control styles text inputs and textareas.
  • form-label styles labels, which should be associated with their controls.
  • form-select styles dropdown selection menus.
  • form-check provides layouts for checkboxes and radio buttons.
  • Bootstrap grid classes create responsive form layouts.
  • required and appropriate input types support browser validation.
  • was-validated activates Bootstrap's validation feedback styling.
  • Clear validation messages help users correct errors.
  • Real registration systems require server-side processing and validation.

Congratulations! You've reached the final lesson of the Bootstrap Elements learning path. Mark it complete below to record your progress!

Your Learning Journey
Bootstrap Elements Learning Path 0 of 7 completed
Lesson 07 / Form Design 0% Complete

Final Lesson Complete! 🎉

You've learned how to create responsive Bootstrap forms, organize inputs, collect user choices, and provide helpful validation feedback. Ready to record your final lesson?

Lesson 07 of 07 · Bootstrap Elements
Bootstrap Elements Mastered!

Congratulations! You've completed all 7 Bootstrap Elements lessons on mC0de. From buttons and navigation to tables and forms, you've built a solid foundation in Bootstrap interface design.

✓ 7 / 7 Lessons Completed · 100%