Form field validation

I’m using the form widget in UI Builder. I have input fields marked as “Required”. I have a button with behavior “Submit”. Attached to this button is a bunch of logic (here, user registration).
When pressing the button, the form fields are correctly evaluated (“Please fill out this field”). However, in addition my logic attached to the button is executed. This fails of course if information is missing.
I would expect that first the form fields are validated and only in case of a positive validation, my logic will be executed. Is there a way to achieve this?
Thx

Hello @Klaas_Klever

The button is just a trigger for submitting a form, so that’s mean “On Click” should work for the Button component.
Try to add your logic in the “On Submit” event handler of Form component which will be called only if all the fields are valid.

Regards, Vlad

I’ve put the logic behind the on-click event of the button. Moving it to the on-submit of the form solves the issue!

By the way: I was looking for a way to copy my logic from on-click to on-submit. There is nothing in the UI which indicates that this is possible (e.g. no mouse context menu entry). However, I was brave and used Ctrl+C and Ctrl+V on my keyboard - and this worked. Maybe this info is useful for others …

Regards,

2 Likes