Form validation latest code sample not working

Hi ,
samples\13_form\04_validation\09_auto_validation.html. this code sample in latest code sample is not working properly. Please suggest a solution.

Hi

Here’s a working example.

The official example doesn’t work because its logic relies on an “user_input” parameter that is not provided by the onChange handler.

Hello,

Thanks for being attentive. I’ll update the sample.

yeah this code is working fine.thank you.
what if my form is like this,

var form = [{cols:[{view:“label”,label:“l1”,width:100,id:“Id1”},
{ view:“text”, name:“test1”,id:“test1”,attributes:{maxlength:2}}]},
{cols:[{view:“label”, label:“l2”,width:100,id:“Id2”},
{ view:“text”, name:“test2”,id:“test2”,attributes:{maxlength:2} }]}];

Can you suggest a solution for this kind of form structure with code sample.

Hi,

Could you provide more details on what exactly you need. Such form structure works well http://webix.com/snippet/5e4ac124

rules: {
“test1”:function(value){ return value > 0;},
“test2”:function(value){ return value > 0;}

},
elementsConfig: {
    on: {
        onChange: function (old_v, new_v) {
            this.getParentView().validate();
        }
    }
}

I want to apply this kind of rule for that form structure. (On entering the text field values should validate as in above sample)

Can I do validation on components one by one…

I recommend you using the getFormView() function to get to a form object. In your case the getParentView() return an object of a layout column, not form.

Here’s you form: http://webix.com/snippet/dc8019da

The validation works, but it does not work as expected: when running validation, it highlights fields, that were not changed/touched by user yet.
See exmple below:
http://webix.com/snippet/55ce9cf5
When changing “l1”, the “l2” highlights even though user did not change this field yet.

Expected: highlight only fields, that were changed by user and did not pass validation.

Is it possible to run validation against a specific (changed) field?

Hello,

I see. Per-item validation is possible only when a form filed features its own validation rule provided in its configuration (validate or required property):

{ view:"text", name:"test1", validate:function(value){ return value > 0;}}, 
{ view:"text", name:"test1", validate:webix.rules.isNotEmpty}, 
{ view:"text", name:"test1", required:true}

Validate function should be called for these fileds separately, not form:

label.validate();

These rules will be triggered during validation of the whole form as well.

Please, check the sample http://webix.com/snippet/4a175e1a

Yeah this works fine,thank you.

Thank you for field-level validation example.