Course Content
Bootstrap 5 Alerts
0/1
Progress Bars
0/1
Spinners
0/1
Pagination
0/1
List Groups
0/1
Bootstrap 5 Scrollspy
0/1
Bootstrap
About Lesson

Modal with Form & Submit Button

  • <form> → Adds a form inside the modal
  • <input> → Creates text fields
  • .btn-primary → Submit button

Example: Modal Form

HTML
<button type="button" class="btn btn-success" data-bs-toggle="modal" data-bs-target="#formModal">Open Form Modal</button>

<div class="modal fade" id="formModal">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title">Contact Form</h5>
        <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
      </div>
      <div class="modal-body">
        <form>
          <label for="name">Name:</label>
          <input type="text" id="name" class="form-control" placeholder="Enter your name">
          <br>
          <button type="submit" class="btn btn-primary">Submit</button>
        </form>
      </div>
    </div>
  </div>
</div>

Output:

Explanation:

  • Creates a contact form inside the modal.