I want to check if field is empty before moving to other part of form divided by div. on a button(not submit) have tried custom validation as given in documentation lightning-input-documentation but i'm getting error
[Cannot read property 'setCustomValidity' of undefined]
HTML:
<lightning-input-field
required
field-name="AccountId"
value={account__c}
class="inputCmp"
></lightning-input-field>
JS:
var inputCmp = this.template.querySelector(".inputCmp");
var value = inputCmp.value;
if (!value) {
inputCmp.setCustomValidity("Please select account");
} else {
inputCmp.setCustomValidity("");
}
inputCmp.reportValidity();