Search code examples
nativescript-vuenativescript-telerik-uinativescript-plugin

How to disable button when RadDataForm is not validated?


disable the button when form is not validated.

{N} Playground

A similar question was asked before. It says it's solved but what exactly was the decent solution? Did I miss something?

Form validation documentation page is broken it has markdown errors.


Solution

  • Add a @propertyValidated="onValidateForm" event listener that triggers on each validation. Then you can use hasValidationErrors() on the form to see if the form is valid. The only trick is that is has to be wrapped in a setTimeout(), like so:

    onValidateForm(event) {
        setTimeout(() => {
            this.validated = !event.object.hasValidationErrors();
            console.log("form valid: " + this.validated);
        }, 100);
    }
    

    For a complete solution, see this {N} Playground.