JSFiddle - React, Tailwind, and code Playground
HTML
<form class="form" action="">
<div class="wrapper-input email">
<input id="email" type="text" name="email" placeholder="youremailaddress@example.com" />
<button class="form-submit submit">Sign-Up</button>
<div class="clear"></div>
</div>
<div class="clear"></div>
<div class="wrapper-input">
<input type="checkbox" id="terms" name="terms" value="Agree"> <span>Click to agree</span>
</div>
</form>
<div class="modal">
<div class="modal-title">
<h4 class="success">Submission Successful!</h4>
<h4 class="error">Submission Error!</h4>
<img class="close" src="img/close-x.png" alt="close" />
</div>
<div class="modal-content">
<p class="success">Sucess</p>
<p class="error">Error!</p>
</div>
</div>
CSS
body { background-color: #fff; }
.clear {
clear: both;
display: block;
float: none;
}
.modal {
display: none;
color: #555;
position: fixed;
top: 25%;
left: 50%;
z-index: 5;
padding: 0;
-moz-box-shadow: 0 0 0 2700px rgba(0, 0, 0, .5);
-webkit-box-shadow: 0 0 0 2700px rgba(0, 0, 0, .5);
box-shadow: 0 0 0 2700px rgba(0, 0, 0, .5);
background: #000;
width: 300px;
margin-left: -150px;
}
.modal.is-visible {
display: block;
}
.modal .modal-title {
color: #000;
position: relative;
}
.modal .modal-title h4 {
display: none;
text-align: center;
font-size: 16px;
font-weight: normal;
margin: 0;
padding: 12px 0;
}
.modal .modal-title .close {
position: absolute;
top: 8px;
right: 7px;
width: 30px;
cursor: pointer;
}
.modal .modal-content {
}
.modal .modal-content p {
display: none;
font-size: 14px;
padding: 22px 20px;
text-align: center;
}
.modal.error .modal-title {
background: #ea212d;
}
.modal.error .error {
display: block;
}
.modal.success .modal-title {
background: #a7cc46;
}
.modal.success .success {
display: block;
}
.form {
padding: 0 10px;
width: 300px;
margin: 0 auto;
}
.form p {
font-weight: normal;
color: #000;
text-align: center;
font-size: 15px;
margin: 18px 0 0;
text-transform: uppercase;
}
.wrapper-input {
position: relative;
margin: 10px 0 0;
}
.wrapper-input input[type="checkbox"] {
position: absolute;
top: 0;
left: 0;
}
.wrapper-input span {
font-size: 14px;
display: block;
color: #000;
padding: 0 0 0 24px;
}
.wrapper-input span a {
color: #000;
}
.form input[type="text"] {
background: #fff url(../img/icon-envelope@2x.png) no-repeat scroll 12px 50%;
background-size: 41px 38px;
border: none;
width: 282px;
margin: 12px 0 0 0;
height: 50px;
padding: 0 5px 0 65px;
font-weight: 200;
font-size: 13px;
...
JavaScript
$(document).ready(function () {
$(".submit").click(function () {
var email = $("#email").val();
var dataString = 'email=' + email;
var terms = $("input:checkbox#terms");
if (!terms.is(":checked")) {
$('.modal').show();
$('.success').hide();
$('.error').show();
}
else if (email === '') {
$('.modal').show();
$('.success').hide();
$('.error').show();
} else {
$.ajax({
type: "/echo/json/",
url: "collect.php",
data: dataString,
success: function () {
$('.modal').show();
$('.success').show();
$('.error').hide();
}
});
}
return false;
});
});
$('.close').click(function(e){
e.preventDefault();
$('.modal').hide();
});