Bootstrap 5: Modal Form Submission

Ruth Jul 09, 2026

In the realm of web development, Bootstrap has long been a go-to library for creating responsive and mobile-first websites. One of its standout features is the modal, a dialog box that appears on top of the current page, providing a more focused environment for users to interact with content or forms. In this article, we'll delve into Bootstrap 5's modal feature, with a specific focus on submitting forms within a modal context.

Bootstrap 5 Modal Form
Bootstrap 5 Modal Form

Before we dive into the specifics of submitting forms within Bootstrap 5 modals, let's briefly recap the basics of modals in Bootstrap 5. A modal in Bootstrap 5 is created using the `

` element with the classes `modal fade` and `show` (for displaying the modal). The modal's content is wrapped in a `
` with the class `modal-dialog`, and the actual content goes inside a `
` with the class `modal-content`.

Bootstrap 5 popup form
Bootstrap 5 popup form

Setting Up a Bootstrap 5 Modal

To start, let's set up a basic Bootstrap 5 modal. We'll use the default modal size, but you can adjust this with the `modal-lg`, `modal-md`, or `modal-sm` classes.

HTML Form Validation with Bootstrap
HTML Form Validation with Bootstrap

Here's a simple example:

```html

```

Triggering the Modal

To trigger the modal, we'll use a button with the `data-bs-toggle` attribute set to `modal` and the `data-bs-target` attribute set to the ID of our modal. Here's how:

```html ```

Adding a Form to the Modal

37 Free Bootstrap Form Templates You Can Try Right Now
37 Free Bootstrap Form Templates You Can Try Right Now

Now, let's add a form to our modal. We'll keep it simple with just a few input fields and a submit button:

```html

```

Submitting the Form in the Modal

Now, let's discuss how to handle form submission within the modal. By default, clicking the submit button will cause the form to submit, but it won't do anything since we haven't specified an action or method. In this case, we'll use JavaScript (or jQuery) to prevent the default form submission and handle it ourselves.

Free 22+ HTML5 Signup & Registration Forms - HTML, CSS
Free 22+ HTML5 Signup & Registration Forms - HTML, CSS

Here's a simple example using jQuery:

```html ```

Using AJAX to Submit the Form

the front page of an email form to book a demo
the front page of an email form to book a demo
the form wizard screen is displayed on an ipad
the form wizard screen is displayed on an ipad
Basic Modal
Basic Modal
📝 Create Text Input Forms and Submit Button in HTML
📝 Create Text Input Forms and Submit Button in HTML
Bootstrap Tutorials: The Best of Azmind | AZMIND
Bootstrap Tutorials: The Best of Azmind | AZMIND
a paper with some writing on it and an image of a woman's name
a paper with some writing on it and an image of a woman's name
GitHub - themesberg/flowbite-admin-dashboard: Free and open-source admin dashboard template built with Tailwind CSS and Flowbite
GitHub - themesberg/flowbite-admin-dashboard: Free and open-source admin dashboard template built with Tailwind CSS and Flowbite
30 Best Free Bootstrap Wizards & Forms 2026 - Colorlib
30 Best Free Bootstrap Wizards & Forms 2026 - Colorlib
HTML/CSS Bootstrap Simple Success Confirmation Popup
HTML/CSS Bootstrap Simple Success Confirmation Popup
BOOTSTRAP INPUT FORM (2020) | HOW TO MAKE FORM IN BOOTSTRAP
BOOTSTRAP INPUT FORM (2020) | HOW TO MAKE FORM IN BOOTSTRAP
Upgrade To Premium Modal | Free Webflow Component
Upgrade To Premium Modal | Free Webflow Component
the login page for wordpress with an arrow pointing up to the account information section
the login page for wordpress with an arrow pointing up to the account information section
the registration form is displayed in purple
the registration form is displayed in purple
Simple Signup Modal | Free Webflow Component
Simple Signup Modal | Free Webflow Component
a screen shot of the timeline sharing page on an iphone, with two people looking at each other
a screen shot of the timeline sharing page on an iphone, with two people looking at each other
Test screen
Test screen
Login With Password | Webflow Components | Memberstack
Login With Password | Webflow Components | Memberstack
Wizard
Wizard
Basic Feedback form
Basic Feedback form
Vueform Builder - Drag And Drop Form Builder for Vue.js
Vueform Builder - Drag And Drop Form Builder for Vue.js

In a real-world scenario, you'd likely want to submit the form data to a server using AJAX. Here's an example using jQuery's `$.ajax` method:

```html ```

And there you have it! You've now learned how to set up a Bootstrap 5 modal, add a form to it, and handle form submission using JavaScript (or jQuery) and AJAX. This knowledge will be invaluable in creating more interactive and user-friendly websites. Happy coding!