javascriptjquerydevexpressdevexpress-mvc

Devexpress - Set editor's "isValid" through Javascript/jQuery


I'm using custom validationfor fields in DevExpress and I need to set if a field is valid or not in my Javascript function.

I'm able to get isValid attribute:

$('#form').dxForm('instance').getEditor('appID').option('isValid')

But I don't know how to set it.


Solution

  • According to DevExtreme documentation about dxForm, option() function has overload which contains 2 arguments:

    option(optionName, optionValue)

    Sets a value to the specified configuration option of this component.

    Parameters:

    • optionName: String The name of the required option.

    • optionValue: any The value you wish to assign to the required option.

    Therefore, you can set isValid validation option with this line:

    $('#form').dxForm('instance').getEditor('appID').option('isValid', true);
    

    Related usage:

    dxForm - FormData update is triggering dxValidatiors on load