I have this input field:
<input
class="form-control"
[(ngModel)]="event.name"
name="name"
required>
And this validation check:
public isEventValid(Event: Event): boolean {
if (Event.name.length == 0) {
this.msgs = [{severity: 'error', summary: '', detail: 'Er is geen Eventnaam ingevuld'}];
return false;
}
if (Event.name.trim().length == 0) {
this.msgs = [{severity: 'error', summary: '', detail: 'De naam mag niet alleen uit spaties bestaan'}];
return false;
}
if (Event.languageId == 0) {
this.msgs = [{severity: 'error', summary: '', detail: 'Er dient een taal te worden gekozen'}];
return false;
}
return true;
}
How can I set the cursor on the input field when one of the if statements is false in the validation check?