$(document).ready(function(){
$('.block1').hide();
$('.block2').hide();
$('.block3').hide();
$(".opcion").click(function(){
$(".block1").show();
$(".block2").hide();
$(".block3").hide();
})
$(".opcion1").click(function(){
$(".block1").hide();
$(".block2").show();
$(".block3").show();
})
})
var form = $("#example-form");
form.validate({
errorPlacement: function errorPlacement(error, element) { element.before(error); },
rules: {
confirm: {
equalTo: "#password"
}
}
});
form.children("div").steps({
headerTag: "h3",
bodyTag: "section",
transitionEffect: "slideLeft",
onStepChanging: function (event, currentIndex, newIndex)
{
if (currentIndex > newIndex)
{
return true;
}
form.validate().settings.ignore = ":disabled,:hidden";
return form.valid();
},
onStepChanged: function (event, currentIndex, newIndex) { //priorIndex
//Este código es para poder regresarte del Paso 4 al 2. Para evitar que se produzca un bucle infinito se debe agregar el return
if (currentIndex === 2 && newIndex === 3)
{
$(this).steps("previous");
return;
}
//Si el usuario en el Paso 2 selecciona la opción A, avanzará al paso 4 en lugar de al Paso 3. De lo contrario avanzará de manera normal
if (currentIndex === 2 && $('input[name="gender"]:checked').val() == "A")
$(this).steps("next");
},
onFinishing: function (event, currentIndex)
{
form.validate().settings.ignore = ":disabled";
return form.valid();
},
onFinished: function (event, currentIndex)
{
alert("Submitted!");
}
});
.title {
display: none;
}
/*
Common
*/
.wizard,
.tabcontrol {
display: block;
width: 100%;
overflow: hidden;
}
.wizard a,
.tabcontrol a {
outline: 0;
}
.wizard ul,
.tabcontrol ul {
list-style: none !important;
padding: 0;
margin: 0;
}
.wizard ul > li,
.tabcontrol ul > li {
display: block;
padding: 0;
}
/* Accessibility */
.wizard > .steps .current-info,
.tabcontrol > .steps .current-info {
position: absolute;
left: -999em;
}
.wizard > .content > .title,
.tabcontrol > .content > .title {
position: absolute;
left: -999em;
}
/*
Wizard
*/
.wizard > .steps {
position: relative;
display: block;
width: 100%;
}
.wizard.vertical > .steps {
display: inline;
float: left;
width: 30%;
}
.wizard > .steps .number {
font-size: 1.429em;
}
.wizard > .steps > ul > li {
width: 20%;
}
.wizard > .steps > ul > li,
.wizard > .actions > ul > li {
float: left;
}
.wizard.vertical > .steps > ul > li {
float: none;
width: 100%;
}
.wizard > .steps a,
.wizard > .steps a:hover,
.wizard > .steps a:active {
display: block;
width: auto;
margin: 0 0.5em 0.5em;
padding: 1em 1em;
text-decoration: none;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
.wizard > .steps .disabled a,
.wizard > .steps .disabled a:hover,
.wizard > .steps .disabled a:active {
background: #eee;
color: #aaa;
cursor: default;
}
.wizard > .steps .current a,
.wizard > .steps .current a:hover,
.wizard > .steps .current a:active {
background: #2184be;
color: #fff;
cursor: default;
}
.wizard > .steps .done a,
.wizard > .steps .done a:hover,
.wizard > .steps .done a:active {
background: #9dc8e2;
color: #fff;
}
.wizard > .steps .error a,
.wizard > .steps .error a:hover,
.wizard > .steps .error a:active {
background: #ff3111;
color: #fff;
}
.wizard > .content {
background: #eee;
display: block;
margin: 0.5em;
min-height: 35em;
overflow: hidden;
position: relative;
width: auto;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
.wizard.vertical > .content {
display: inline;
float: left;
margin: 0 2.5% 0.5em 2.5%;
width: 65%;
}
.wizard > .content > .body {
float: left;
position: absolute;
width: 95%;
height: 95%;
padding: 2.5%;
}
.wizard > .content > .body ul {
list-style: disc !important;
}
.wizard > .content > .body ul > li {
display: list-item;
}
.wizard > .content > .body > iframe {
border: 0 none;
width: 100%;
height: 100%;
}
.wizard > .content > .body input {
display: block;
border: 1px solid #ccc;
}
.wizard > .content > .body input[type="checkbox"] {
display: inline-block;
}
.wizard > .content > .body input.error {
background: rgb(251, 227, 228);
border: 1px solid #fbc2c4;
color: #8a1f11;
}
.wizard > .content > .body label {
display: inline-block;
margin-bottom: 0.5em;
}
.wizard > .content > .body label.error {
color: #8a1f11;
display: inline-block;
margin-left: 1.5em;
}
.wizard > .actions {
position: relative;
display: block;
text-align: right;
width: 100%;
}
.wizard.vertical > .actions {
display: inline;
float: right;
margin: 0 2.5%;
width: 95%;
}
.wizard > .actions > ul {
display: inline-block;
text-align: right;
}
.wizard > .actions > ul > li {
margin: 0 0.5em;
}
.wizard.vertical > .actions > ul > li {
margin: 0 0 0 1em;
}
.wizard > .actions a,
.wizard > .actions a:hover,
.wizard > .actions a:active {
background: #2184be;
color: #fff;
display: block;
padding: 0.5em 1em;
text-decoration: none;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
.wizard > .actions .disabled a,
.wizard > .actions .disabled a:hover,
.wizard > .actions .disabled a:active {
background: #eee;
color: #aaa;
}
.wizard > .loading {}
.wizard > .loading .spinner {}
/*
Tabcontrol
*/
.tabcontrol > .steps {
position: relative;
display: block;
width: 100%;
}
.tabcontrol > .steps > ul {
position: relative;
margin: 6px 0 0 0;
top: 1px;
z-index: 1;
}
.tabcontrol > .steps > ul > li {
float: left;
margin: 5px 2px 0 0;
padding: 1px;
-webkit-border-top-left-radius: 5px;
-webkit-border-top-right-radius: 5px;
-moz-border-radius-topleft: 5px;
-moz-border-radius-topright: 5px;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
}
.tabcontrol > .steps > ul > li:hover {
background: #edecec;
border: 1px solid #bbb;
padding: 0;
}
.tabcontrol > .steps > ul > li.current {
background: #fff;
border: 1px solid #bbb;
border-bottom: 0 none;
padding: 0 0 1px 0;
margin-top: 0;
}
.tabcontrol > .steps > ul > li > a {
color: #5f5f5f;
display: inline-block;
border: 0 none;
margin: 0;
padding: 10px 30px;
text-decoration: none;
}
.tabcontrol > .steps > ul > li > a:hover {
text-decoration: none;
}
.tabcontrol > .steps > ul > li.current > a {
padding: 15px 30px 10px 30px;
}
.tabcontrol > .content {
position: relative;
display: inline-block;
width: 100%;
height: 35em;
overflow: hidden;
border-top: 1px solid #bbb;
padding-top: 20px;
}
.tabcontrol > .content > .body {
float: left;
position: absolute;
width: 95%;
height: 95%;
padding: 2.5%;
}
.tabcontrol > .content > .body ul {
list-style: disc !important;
}
.tabcontrol > .content > .body ul > li {
display: list-item;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-steps/1.1.0/jquery.steps.js"></script>
<script src="https://ajax.aspnetcdn.com/ajax/jquery.validate/1.15.0/jquery.validate.js"></script>
<form id="example-form" action="#">
<div>
<h3>Account</h3>
<section>
<label for="userName">User name *</label>
<input id="userName" name="userName" type="text" class="required">
<label for="password">Password *</label>
<input id="password" name="password" type="text" class="required">
<label for="confirm">Confirm Password *</label>
<input id="confirm" name="confirm" type="text" class="required">
<p>(*) Mandatory</p>
</section>
<h3>Profile</h3>
<section>
<label for="name">First name *</label>
<input id="name" name="name" type="text" class="required">
<label for="surname">Last name *</label>
<input id="surname" name="surname" type="text" class="required">
<label for="email">Email *</label>
<input id="email" name="email" type="text" class="required email">
<label for="address">Address</label>
<input id="address" name="address" type="text">
<div class="mobile-wrapper">
<label for="rate" class="title mobile-block">choose an option</label>
<div class="radio">
<input type="radio" id="si" class="opcion" name="gender" value="A">
<label for="si">A</label><br>
<input type="radio" id="no" class="opcion1" name="gender" value="B">
<label for="no">B</label><br>
</div>
<div class="block1">
<label for="phone">phone *</label>
<input id="phone" name="phone" type="text" class="required">
</div>
</div>
<p>(*) Mandatory</p>
</section>
<h3>hol</h3>
<section>
<div class="block2">
<label for="number phone">number phone *</label>
<input id="" name="number phone" type="text" class="required">
</div>
<div class="block3">
<label for="car">Car</label>
<input id="phone" name="car" type="text" class="required">
</div>
</section>
<h3>Finish</h3>
<section>
<input id="acceptTerms" name="acceptTerms" type="checkbox" class="required"> <label for="acceptTerms">I agree with the Terms and Conditions.</label>
</section>
</div>
</form>