3
I have a form for registration divided into tabs, where the tabs are disabled until the user clicks on the button to enable and go to the next one. The problem is that the way it is the user has to enable the button and then click on the next tab. I need that when the user clicks the button NEXT it is directed to the next tab automatically, and add a button to return to the previous tab.
My code is like this currently: 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
This resolved the next part correctly. You would have a hint of how to add the button to return to the previous tab?
– Randrade