Hidden Form Fields, Ignore When Submit

I have this code that gets the values of richselects. But it gets all of them in the form, even the hidden ones. The hidden ones have no options until the parent of the hidden one is active (these can be optional). Therefore when the form is submitted, I get an undefined error because these hidden fields have no value.


var formValues = form.getValues();
for(var i in form.elements){
    var input = form.elements[i];
    if(input.getText){
        formValues[input.config.name] = input.getText();
    }
}

Is there a way to ignore hidden fields within the block of code above?

Also,
The hidden richselects, when made active - How do I then make them required?

Well, you can provide an additional parameter to the getValue() method to make it collect values from visible fields only:

form.getValues({hidden:false});

And you can make the hidden richselect required initially - hidden fields are not be validated. Only don’t forget to clearValidation on show/hide.

Check the snippet, please http://webix.com/snippet/519ef8b0

Excellent! That’s just what I needed. Thank you, worked great. input.isVisible() is a good check!