Custom Web Design & Development

Bootstrap Modal + Contact Form


Or a pop-up contact form


For purposes of this tutorial, I won't describe how to make a form-processing script. If you don't already have a script, go to my blog where I discuss in 3-part depth how to create a self-contained form with PHP code. See Responsive Contact Form with Bootstrap and PHP.

This code demo is built with Bootstrap so let's begin with a basic Bootstrap document. I'm using Bootstrap 3.3.6 here but feel free to use the latest.

Basic Bootstrap document

<!doctype html> 
<meta charset="utf-8"> 
<title>Bootstrap Starter Page</title> 
<meta name="viewport" content="width=device-width, initial-scale=1"> 
<meta http-equiv="X-UA-Compatible" content="IE=edge"> 
<!--[if lt IE 9]> 
<script src=""></script> 
<link rel="stylesheet" href="">
<div class="container">
<div class="row">


<!--latest jQuery--> 
<script src="" integrity="sha256-lZFHibXzMHo3GGeehn1hudTAP3Sc0uKXBXAzHX1sjtk=" crossorigin="anonymous"></script> 
<script src=""></script> 

Bootstrap Button & Modal Window

<!--Button trigger for modal--> 
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">CONTACT US</button>
<!--Begin Modal Window--> 
<div class="modal fade left" id="myModal"> 
<div class="modal-dialog"> 
<div class="modal-content"> 
<div class="modal-header"> 
<h3 class="pull-left no-margin">Contact Form</h3>
<button type="button" class="close" data-dismiss="modal" title="Close"><span class="glyphicon glyphicon-remove"></span>
<div class="modal-body">


<div class="modal-footer"> 
<div class="col-xs-10 pull-left text-left text-muted"> 
<small><strong>Privacy Policy:</strong>
Lorem ipsum dolor sit amet consectetur adipiscing elit. 
Mauris vitae libero lacus, vel hendrerit nisi! Maecenas quis 
velit nisl, volutpat viverra felis. Vestibulum luctus mauris 
sed sem dapibus luctus.</small> 
<button class="btn-sm close" type="button" data-dismiss="modal">Close</button> 

Add Contact Form to line 15, modal-body div

<!--NOTE: you will need to provide your own form processing script--> 
<form class="form-horizontal" role="form" method="post" action="form_to_email_script.php "> 
<span class="required">* Required</span> 
<div class="form-group"> 
<label for="name" class="col-sm-3 control-label">
<span class="required">*</span> Name:</label> 
<div class="col-sm-9"> 
<input type="text" class="form-control" id="name" name="name" placeholder="First & Last" required> 
<div class="form-group"> 
<label for="email" class="col-sm-3 control-label">
<span class="required">*</span> Email: </label> 
<div class="col-sm-9"> 
<input type="email" class="form-control" id="email" name="email" placeholder="" required> 
<div class="form-group"> 
<label for="message" class="col-sm-3 control-label">
<span class="required">*</span> Message:</label> 
<div class="col-sm-9"> 
<textarea name="message" rows="4" required class="form-control" id="message" placeholder="Comments"></textarea> 
<div class="form-group"> 
<label for="human" class="col-sm-3 control-label">
<span class="required">*</span> Human or Bot:</label> 
<div class="col-sm-4"> 
<h3 class="human">Six + 6 = ?</h3> 
<input type="number" class="form-control" id="human" name="human" placeholder="Enter sum in digits"> 
<div class="form-group"> 
<div class="col-sm-offset-3 col-sm-6 col-sm-offset-3"> 
<button type="submit" id="submit" name="submit" class="btn-lg btn-primary">SUBMIT</button> 
<!--end Form--></form>

Finally, add a little CSS to your custom style sheet

.required {
.human {margin: 0 0 0 12px}

And there you have it. A pop-up contact form built entirely with Bootstrap's form classes and modal window component.