"Step Form Wizard and validation with Prev btn"
Bootstrap 3.3.0 Snippet by infowest7l

<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 ----------> <div class="container"> <div class="stepwizard"> <div class="stepwizard-row setup-panel"> <div class="stepwizard-step"> <a href="#step-1" type="button" class="btn btn-primary btn-circle"><strong class="large">1</strong></a> <p>Índice Socioeconômico do Aluno</p> </div> <div class="stepwizard-step"> <a href="#step-2" type="button" class="btn btn-default btn-circle" disabled="disabled">2</a> <p>Cadastro de Membros do Grupo Familiar</p> </div> <div class="stepwizard-step"> <a href="#step-3" type="button" class="btn btn-default btn-circle" disabled="disabled">3</a> <p>Situação socioeconômica do Membro do Grupo Familiar</p> </div> <div class="stepwizard-step"> <a href="#step-4" type="button" class="btn btn-default btn-circle" disabled="disabled">4</a> <p>Membros do Grupo Familiar</p> </div> <div class="stepwizard-step"> <a href="#step-5" type="button" class="btn btn-default btn-circle" disabled="disabled">5</a> <p>Gravar e Finalizar Inscrição</p> </div> </div> </div> <form role="form"> <div class="row setup-content" id="step-1"> <div class="col-xs-12"> <div class="col-md-12"> <h3>Índice Socioeconômico do Aluno</h3> <div class="form-group"> <label class="control-label">First Name</label> <input maxlength="100" type="text" required="required" class="form-control" placeholder="Enter First Name" /> </div> <button class="btn btn-primary nextBtn btn-lg pull-right" type="button" >Gravar e Prosseguir</button> </div> </div> </div> <div class="row setup-content" id="step-2"> <div class="col-xs-12"> <div class="col-md-12"> <div class="form-group"> <label class="control-label">Cadastro de Membros do Grupo Familiar</label> <input maxlength="200" type="text" required="required" class="form-control" placeholder="Enter Company Name" /> </div> <button class="btn btn-default prevBtn btn-lg pull-left" type="button" >Voltar</button> <button class="btn btn-primary nextBtn btn-lg pull-right" type="button" >Gravar e Prosseguir</button> </div> </div> </div> <div class="row setup-content" id="step-3"> <div class="col-xs-12"> <div class="col-md-12"> <div class="form-group"> <label class="control-label">Índice Socioeconômico do Membro do Grupo Familiar</label> <input maxlength="200" type="text" required="required" class="form-control" placeholder="Enter skill or skills" /> </div> <button class="btn btn-default prevBtn btn-lg pull-left" type="button" >Voltar</button> <button class="btn btn-primary nextBtn btn-lg pull-right" type="button" >Gravar e Prosseguir</button> </div> </div> </div> <div class="row setup-content" id="step-4"> <div class="col-xs-12"> <div class="col-md-12"> <label class="control-label">Lista dos Membros do Grupo Familiar</label> <input maxlength="200" type="text" required="required" class="form-control" placeholder="Teste" /> <button class="btn btn-default prevBtn btn-lg pull-left" type="button" >Voltar</button> <button class="btn btn-primary nextBtn btn-lg pull-right" type="button" >Gravar e Prosseguir</button> </div> </div> </div> <div class="row setup-content" id="step-5"> <div class="col-xs-12"> <div class="col-md-12"> <label class="control-label">Gravar e Finalizar Inscrição</label> <button class="btn btn-default prevBtn btn-lg pull-left" type="button" >Voltar</button> <button class="btn btn-success btn-lg pull-right" type="submit">Gravar e Finalizar!</button> </div> </div> </div> </form> </div>
body{ margin-top:20px; } .stepwizard-step p { margin-top: 5px; } .stepwizard-row { display: table-row; } .stepwizard { display: table; width: 100%; position: relative; } .stepwizard-step button[disabled] { opacity: 1 !important; filter: alpha(opacity=100) !important; } .stepwizard-row:before { top: 14px; bottom: 0; position: absolute; content: " "; width: 100%; height: 1px; background-color: #ccc; z-order: 0; } .stepwizard-step { display: table-cell; text-align: center; position: relative; } .btn-circle { width: 30px; height: 30px; text-align: center; padding: 6px 0; font-size: 12px; line-height: 1.428571429; border-radius: 15px; }
$(document).ready(function () { var navListItems = $('div.setup-panel div a'), allWells = $('.setup-content'), allNextBtn = $('.nextBtn'), allPrevBtn = $('.prevBtn'); allWells.hide(); navListItems.click(function (e) { e.preventDefault(); var $target = $($(this).attr('href')), $item = $(this); if (!$item.hasClass('disabled')) { navListItems.removeClass('btn-primary').addClass('btn-default'); $item.addClass('btn-primary'); allWells.hide(); $target.show(); $target.find('input:eq(0)').focus(); } }); allNextBtn.click(function(){ var curStep = $(this).closest(".setup-content"), curStepBtn = curStep.attr("id"), nextStepWizard = $('div.setup-panel div a[href="#' + curStepBtn + '"]').parent().next().children("a"), curInputs = curStep.find("input[type='text'],input[type='url']"), isValid = true; $(".form-group").removeClass("has-error"); for(var i=0; i<curInputs.length; i++){ if (!curInputs[i].validity.valid){ isValid = false; $(curInputs[i]).closest(".form-group").addClass("has-error"); } } if (isValid) nextStepWizard.removeAttr('disabled').trigger('click'); }); allPrevBtn.click(function(){ var curStep = $(this).closest(".setup-content"), curStepBtn = curStep.attr("id"), prevStepWizard = $('div.setup-panel div a[href="#' + curStepBtn + '"]').parent().prev().children("a"); $(".form-group").removeClass("has-error"); prevStepWizard.removeAttr('disabled').trigger('click'); }); $('div.setup-panel div a.btn-primary').trigger('click'); });

Related: See More


Questions / Comments: