Join the Team Forms community

T
S
A
C
H

Prevent custom button action execution on validation failure

Updated last month


I created the following dual actions on the button, with the 'show validations' option turned on.

However, if the validation fails, the other actions are still executed on click except for Submit.

I don't want to use the 'Disable on invalid forms' option because it doesn't show me the invalid components.

How do I make sure that all actions are only executed if the validation succeeds?

Marked as solution

Hi Muffins

There is an undocumented function you can call called instance.root.checkValidity()which will return true if all fields are valid and false if there are any invalid fields in the response. Using this function, you could conditionally run different parts of your code for example:

JavaScript
instance.emit("submitButton")
if(instance.root.checkValidity()){
	// Do something
}


View full solution
E
M
1 comment·1 reply

Hi Muffins

There is an undocumented function you can call called instance.root.checkValidity()which will return true if all fields are valid and false if there are any invalid fields in the response. Using this function, you could conditionally run different parts of your code for example:

JavaScript
instance.emit("submitButton")
if(instance.root.checkValidity()){
	// Do something
}


it works very well.