I want to have Parsley not validate an input if it is not visible. I have a large multi-step survey that reveals new sections as you complete it. Each section is in its own tag, and within each form I can have multiple sections that reveal as you go through it. I am currently using 1.x, and this is how I do it now:
$('#' + formID).parsley({
errors : {
container: function(element) {
var $container = element.parent().find('parsley-container');
if($container.length === 0)
{
if($(element).hasClass('text-hide') && !$(element).hasClass('not-select'))
{
$(element).prev().addClass('is-error');
}
else
{
$container = $('<div class="parsley-container"></div>').insertAfter(element);
}
}
return $container;
}
},
listeners: {
onFieldValidate: function(elem) {
if(!$(elem).is(':visible'))
{
return true;
}
return false;
}
}
It is in the listeners section that I only validate fields that are visible. How can I do this in Parsley 2.x? I've been going through the documentation and I can't find an equivalent way of doing it. I know there are validation groups in 2.x, but is there a way to just do it like I did in 1.x?