Using validations for database insert with code

I’m using the insert function for an onClick event to inset the information with code. But I want to submit the information with the input validation.

Then you should set required on the fields and also when all fields are done or when the SAVE button is clicked you do the below for all fields.

let isValid = $w(“#myElement”).valid; // false or true