"Modal Validate Email"
Bootstrap 3.3.0 Snippet by muzikiii

<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <form id='forminsertEmail' commandName='insert' cssClass='form-horizontal' > <div class="modal fade modalConfirmEmail" id="modalConfirmEmail"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <h4 class="modal-title"><i class='glyphicon glyphicon-envelope text-info'></i> Comfirm E-mail</h4> </div> <br> <div class="modal-body"> <div class="col-sm-offset-4" style="text-align: center;"> <div class='form-group' > <div class='input-group col-xs-8' data-validate="email"> <input type="text" class="form-control " name="validate-email" id="validate-email" placeholder="Email Address" required> <span class="input-group-addon danger"><span class="glyphicon glyphicon-exclamation-sign"></span></span> </div> </div> </div> </div> <div class="modal-footer" style="text-align: center; "> <button type="button" class="btn btn-info" disabled id="btnConfirmEmail" data-dismiss="modal">Submit</button> <button type="reset" class="btn btn-default" data-dismiss="modal">Cancel</button> </div> </div> </div> </div> </form> <div class="container"> <div class="row" style="margin-top:40px;"> <div class="col-md-12 text-center"> <p class="text-center"> Validate Email with Modal </p> <!-- Button trigger modal --> <button id="btnConfirm" type="button" class="btn btn-info btn-lg" onclick="getConfirm()"> <i class='glyphicon glyphicon-envelope'></i> E-mail </button> </div> </div> </div>
.input-group-addon.primary { color: rgb(255, 255, 255); background-color: rgb(50, 118, 177); border-color: rgb(40, 94, 142); } .input-group-addon.success { color: rgb(255, 255, 255); background-color: rgb(92, 184, 92); border-color: rgb(76, 174, 76); } .input-group-addon.info { color: rgb(255, 255, 255); background-color: rgb(57, 179, 215); border-color: rgb(38, 154, 188); } .input-group-addon.warning { color: rgb(255, 255, 255); background-color: rgb(240, 173, 78); border-color: rgb(238, 162, 54); } .input-group-addon.danger { color: rgb(255, 255, 255); background-color: rgb(217, 83, 79); border-color: rgb(212, 63, 58);
function getConfirm() { $("#modalConfirmEmail").modal("show"); } $('#btnConfirmEmail').click(function() { /* To do Something */ }); $(document).ready(function() { $('.input-group input[required]').on('keyup change', function() { var $form = $(this).closest('form'), $group = $(this).closest('.input-group'), $addon = $group.find('.input-group-addon'), $icon = $addon.find('span'), state = false; if (!$group.data('validate')) { state = $(this).val() ? true : false; }else if ($group.data('validate') == "email") { state = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test($(this).val()) } if (state) { $addon.removeClass('danger'); $addon.addClass('success'); $icon.attr('class', 'glyphicon glyphicon-ok'); }else{ $addon.removeClass('success'); $addon.addClass('danger'); $icon.attr('class', 'glyphicon glyphicon-remove'); } if ($form.find('.input-group-addon.danger').length == 0) { $form.find('[type="button"]').prop('disabled', false); }else{ $form.find('[type="button"]').prop('disabled', true); } }); $('.input-group input[required], .input-group textarea[required], .input-group select[required]').trigger('change'); });

Related: See More


Questions / Comments: