This is a bit messier than I would normally like, but there weren't many options since the tabs are not input elements that can just be disabled.
Instead, I wrote a couple of scripts that clone all the nav elements into hidden contains and strips the default handlers off the originals.
A new handler is added to the elements, which validates the active page, and if the page is valid, it will trigger a click event on the hidden clone.
The page validation script leverages the parsley validation already built into Forms, so no extra checks/messages are needed.
$(document).ready(function(){
// create container for cloned nav tabs
let container = $('<div style="display:none !important;"></div>');
// pagination tabs
$('.cf-pagination-tabs li').each(function(){
// clone tab to hidden container
var c = $(this).clone(true, true);
container.append(c);
// remove/replace event handlers
$(this).off().on('click',function(){
// get results of page validation
if (pageValid()) {
$(c).click(); // trigger click on hidden tab
if ($(this).is('li')) $(this).addClass('active'); // make tab active
}
});
});
$('.cf-pagination-tabs').parent().append(container);
// navigation buttons
$('.cf-pagination-btn').each(function(){
// create container for nav buttons
var box = $('<div style="display:none !important;"></div>');
$(this).find('input').each(function(){
// clone button to hidden container
var c = $(this).clone(true,true);
box.append(c);
// remove/replace event handlers
$(this).off().on('click',function(e){
if (pageValid()) $(c).click(); // trigger click on hidden btn
});
});
$(this).append(box);
});
});
// page validation function
function pageValid(){
var valid = true; // default output
// validate fields on active page
$('.cf-page.active :input:not([readonly]):visible').each(function(){
// show validation errors
$(this).parsley().validate();
// change output for invalid field if none detected
if (valid && !$(this).parsley().isValid()) {
$(this).focus(); // focus on first error
valid = false; // flag error
}
});
return valid;
}
Everything seemed to work as expected on my end.