1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22type FormElement =
| HTMLIonInputElement
| HTMLIonTextareaElement
| HTMLIonSelectElement
| HTMLIonCheckboxElement
| HTMLIonToggleElement
| HTMLElement;
/**
* Checks if the form element is in an invalid state based on
* Ionic validation classes.
*
* @param el The form element to check.
* @returns `true` if the element is invalid, `false` otherwise.
*/
export const checkInvalidState = (el: FormElement): boolean => {
const hasIonTouched = el.classList.contains('ion-touched');
const hasIonInvalid = el.classList.contains('ion-invalid');
return hasIonTouched && hasIonInvalid;
};