Validate user input before saving it

Hello,

my Block contains multiple Inputs. One is required another one contains an email address. The Required option is selected for one Input, and the Type is set to Email for the other. The Outline of the Input turns red when the values are not valid.

How can I catch these invalid inputs before saving it to the data base?

Thanks

Hi @Joerg!

Thank you for writing us!
It seems like you added save login on “click” event for “Submit” button of our form.
Could you, please, try to move your save logic to “submit” form event. This event is fired only when form inputs are valid.

Please, let me know about results.

Regards, Andriy

Thanks, Andriy,

currently I simply use Inputs in a Block, not a Form element. Can I validate the inputs this way or do I need to use a Form element?

Thanks

Inputs validation was designed to be used together with forms, so you should wrap your inputs in form if you want to use client-side validation.

Ragards, Andriy