I added more code for you to inspect. I tried to clean it up so you can see it better. Please forgive any mistakes in my cleanup process.
`
$(document).ready(function() {
var $sections = $('.form_section');
function navigateTo(index) {
//Mark the current section with the class 'current'
$sections
.removeClass('current')
.eq(index)
.addClass('current');
//Show only the navigation buttons that make sense for the current section:
$('.form_navigation2 .previous').toggle(index > 0);
var atTheEnd = index >= $sections.length - 1;
$('.form_navigation1 .signup_now_button').toggle(!atTheEnd);
$('.form_navigation2 [type=submit]').toggle(atTheEnd);
}
function curIndex() {
//Return the current index by looking at which section has the class 'current'
return $sections.index($sections.filter('.current'));
}
$('.form_navigation2 .previous').click(function() {
navigateTo(curIndex() - 1);
$('#the_form').reset;
$('.form_navigation1 .submit_button').click(function() {
$('#the_form').parsley().whenValidate({
group: 'block-' + curIndex()
}).done(function() {
navigateTo(curIndex() + 1);
});
if ($('.part1').val() == 'option1') {
$('.group2,.group3,.group5').hide();
}
if ($('.part2').val() == 'option2') {
$('.group1,.group2,.group5').hide();
}
//Prepare sections by setting the data-parsley-group
attribute to 'block-0', 'block-1', etc.
$sections.each(function(index, section) {
$(section).find(':input').attr('data-parsley-group', 'block-' + index);
});
navigateTo(0); //Start at the beginning
});
`