react icon indicating copy to clipboard operation
react copied to clipboard

Validation for custom component

Open Anandks1993 opened this issue 5 years ago • 0 comments

Hi,

I am working on to create a custom component in the form builder, I am able to validate the data on submission via checkValidity method but I need the submit button to be disabled if the form is invalid.

And right now the error message is showing up in alert box but I need that to show below the custom component.

Please help me to achieve proper validation for the custom component.

Current checkValidity function:

checkValidity(data, dirty) {

        if (this.originalComponent.validate.required) {
            if (!data.customComponent.agree) {
                this.invalid = true;
                this.error = 'This error message appears in alert box';
                return false;
            }

            if (data.customComponent.agree && !data.customComponent.data) {
                this.invalid = true;
                this.error = 'This error message appears in alert box';
                return false;
            }
        }

        return true;
    }

Anandks1993 avatar Jan 07 '21 15:01 Anandks1993