Bootstrap Registration Form CodePen

Ruth Jul 09, 2026

Bootstrap, a popular open-source CSS framework, simplifies responsive web development by providing pre-defined classes and components. When it comes to creating registration forms, Bootstrap offers a clean, responsive, and customizable solution. Let's dive into a comprehensive guide on creating a Bootstrap registration form, using CodePen as our playground.

55 Best Free Bootstrap Registration Form Designs 2026 - Colorlib
55 Best Free Bootstrap Registration Form Designs 2026 - Colorlib

CodePen is an online code editor that allows you to write HTML, CSS, and JavaScript in the browser and see the results in real-time. It's an excellent tool for experimenting with Bootstrap and other libraries. Let's get started with our Bootstrap registration form.

Best Free Bootstrap Login Forms » CSS Author
Best Free Bootstrap Login Forms » CSS Author

Setting Up the Bootstrap Registration Form

First, we need to include the Bootstrap CSS and JavaScript libraries in our CodePen editor. You can find these in the 'Settings' tab under 'JavaScript' and 'CSS' respectively. For this example, we'll use the CDN links:

Bootstrap Responsive Design Registration Form
Bootstrap Responsive Design Registration Form

<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>

Creating the Form Structure

Bootstrap Registration Forms: 3 Free Responsive Templates | AZMIND
Bootstrap Registration Forms: 3 Free Responsive Templates | AZMIND

Now, let's create the basic structure of our registration form using Bootstrap's grid system and form classes.

<div class="container">
<div class="row justify-content-center">
<div class="col-md-6">
<form>
<div class="form-group">
<label for="username">Username</label>
<input type="text" class="form-control" id="username" placeholder="Enter username">
</div>
<div class="form-group">
<label for="email">Email address</label>
<input type="email" class="form-control" id="email" placeholder="Enter email">
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" class="form-control" id="password" placeholder="Password">
</div>
<button type="submit" class="btn btn-primary">Register</button>
</form>
</div>
</div>
</div>

Styling and Customizing the Form

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

Bootstrap provides several customization options. Let's add some basic styling to our form:

<style>
form {
max-width: 360px;
margin: auto;
}
label {
font-weight: bold;
}
button {
width: 100%;
}
</style>

Adding Interactive Features

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

Let's make our form more interactive by adding some basic JavaScript validation using Bootstrap's modal for error messages.

Creating a Bootstrap Modal

Bootstrap Registration Page
Bootstrap Registration Page
the bootstap login and register forms page
the bootstap login and register forms page
HTML Form Validation with Bootstrap
HTML Form Validation with Bootstrap
Free Bootstrap Registration Form
Free Bootstrap Registration Form
Dual Design Registration Form
Dual Design Registration Form
Registration Form
Registration Form
the form wizard screen is displayed on an ipad
the form wizard screen is displayed on an ipad
Register Form Design Using HTML and CSS
Register Form Design Using HTML and CSS
the registration form is shown in green and white
the registration form is shown in green and white
a screenshot of a business information form on a computer screen with the text create new account
a screenshot of a business information form on a computer screen with the text create new account
the registration form for an office use is shown in green and white colors, with black lines
the registration form for an office use is shown in green and white colors, with black lines
Student Registration Form in HTML with CSS | Completely Free
Student Registration Form in HTML with CSS | Completely Free
the sign up screen for an app
the sign up screen for an app
BOOTSTRAP INPUT FORM (2020) | HOW TO MAKE FORM IN BOOTSTRAP
BOOTSTRAP INPUT FORM (2020) | HOW TO MAKE FORM IN BOOTSTRAP
Formulaire à remplir
Formulaire à remplir
Bootstrap Fieldset Legend: How To + Examples + Template | AZMIND
Bootstrap Fieldset Legend: How To + Examples + Template | AZMIND
Form generator: Registration Form Demo
Form generator: Registration Form Demo
Bootstrap 5 popup form
Bootstrap 5 popup form
Responsive Registration Form in HTML and CSS Tutorial
Responsive Registration Form in HTML and CSS Tutorial
Angular Material Registration Form Template
Angular Material Registration Form Template

First, we'll create a Bootstrap modal to display error messages:

<div class="modal fade" id="errorModal" tabindex="-1" role="dialog" aria-labelledby="errorModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="errorModalLabel">Error</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body" id="errorMessage"></div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>

Adding JavaScript Validation

Now, let's add JavaScript to validate the form fields and display the modal if there are any errors:

<script>
document.querySelector('form').addEventListener('submit', function(event) {
event.preventDefault();
var username = document.getElementById('username').value;
var email = document.getElementById('email').value;
var password = document.getElementById('password').value;
if (!username || !email || !password) {
document.getElementById('errorMessage').innerText = 'All fields are required.';
$('#errorModal').modal('show');
} else if (password.length < 6) {
document.getElementById('errorMessage').innerText = 'Password must be at least 6 characters.';
$('#errorModal').modal('show');
} else {
alert('Form submitted successfully!');
}
});
</script>

With this, we've created a responsive, interactive Bootstrap registration form using CodePen. You can further customize this form to fit your specific needs. Happy coding!