I have a registration form divided into tabs, where the tabs are disabled until the user clicks the button to enable and go to next. The problem is that the way the user is has to enable the button and then click on the next tab. I need when the user clicks the NEXT button it will be directed to the next tab automatically, and add a button to return to the previous tab.
My code is currently so: JSFiddle
HTML:
<ul class="nav nav-pills">
<li class="active"><a href="#home" data-toggle="tab">Home</a></li>
<li><a href="#profile" data-toggle="tab">Profile</a></li>
<li><a href="#messages" data-toggle="tab">Messages</a></li>
</ul>
<div id='content' class="tab-content">
<div class="tab-pane active" id="home">
Nome: <input/><br/>
<button>Próximo</button>
</div>
<div class="tab-pane" id="profile">
CPF: <input/><br/>
<button>Próximo</button>
</div>
<div class="tab-pane" id="messages">
<button>Salvar</button>
</div>
</div>
JS:
$(document).ready(function() {
/*disable non active tabs*/
$('.nav li').not('.active').addClass('disabled');
$('.nav li').not('.active').find('a').removeAttr("data-toggle");
$('button').click(function(){
/*enable next tab*/
$('.nav li.active').next('li').removeClass('disabled');
$('.nav li.active').next('li').find('a').attr("data-toggle","tab")
});
});
I need something like this: Example