Validate required fields
Thu Jul 11 2024 17:47:23 GMT+0000 (Coordinated Universal Time)
Saved by
@gbritgs
const allValid = [...this.template.querySelectorAll('lightning-input')].reduce((validSoFar, inputField) => {
inputField.reportValidity();
return validSoFar && inputField.checkValidity();
}, true);
if (allValid) {
console.log('All fields are valid');
} else {
console.log('Please complete all required fields.');
}
content_copyCOPY
Comments