First thanks for a great product. I spent months trying to integrate a bunch of COTS products and finally decided to throw them all out and build from scratch with Chronoforms. If I'd bitten the bullet and done this first I'd be finished by now😟
Anyway, I've built a multi-tab login / register form with separate submit buttons which is working well. I wrote the script below to dynamically disable validation on the inactive tab so it doesn't prevent submit. It works as expected but only enables/disables validation on the first field in each tab. Subsequent calls to gvalidate fail with TypeError: gval is null..return gval.get();
I've spent lots of time getting to this stage and it's *almost* right. I can smell success!
Any ideas on how I can make multiple calls to gvalidate succeed?
Thanks
John
Anyway, I've built a multi-tab login / register form with separate submit buttons which is working well. I wrote the script below to dynamically disable validation on the inactive tab so it doesn't prevent submit. It works as expected but only enables/disables validation on the first field in each tab. Subsequent calls to gvalidate fail with TypeError: gval is null..return gval.get();
I've spent lots of time getting to this stage and it's *almost* right. I can smell success!
Any ideas on how I can make multiple calls to gvalidate succeed?
Thanks
John
jQuery(document).ready(function(){
// Enable validation for login tab fields on load
vgRequired("input.register", "disable");
vgRequired("input.login", "enable");
// Get the active CF5 bootstrap tab
jQuery('a[data-g-toggle="tab"]').on('shown.bs.tab', function (e) {
var targetTab = jQuery(e.target).attr("href");
if ((targetTab == '#register-tab')) { // register tab clicked
vgRequired("input.register", "enable");
vgRequired("input.login", "disable");
} else if ((targetTab == '#login-tab')){ // login tab clicked
vgRequired("input.register", "disable");
vgRequired("input.login", "enable");
}
});
});
function vgRequired(vgTypeClass, enableDisable) {
// Loop thru input elements
jQuery(vgTypeClass).each(function (index){
targetField = "#"+this.id;
if (enableDisable == "enable") {
jQuery(targetField).addClass('validate["required"]');
jQuery(targetField).gvalidate('get').enable();
} else if (enableDisable == "disable")
jQuery(targetField).removeClass('validate["required"]');
jQuery(targetField).gvalidate('get').reset();
});
}