How to show ion-input error-text without the user "touching" the field (Ionic 7)

Upgrading to Ionic7 and trying to use the ion-input field with the following snippet.

ion-input name=“username” type=“email” label=“Email” labelPlacement=“fixed” required placeholder=“Your Email” error-text=“Email is required”>

If the user doesn’t provide any input into the input field, is there a way to trigger showing the error message? The user is clicking a button and I’m trying to show the error message on a validation check. Since the field wasn’t “touched”, the error message isn’t showing.

How do I trigger the showing of the error message programmatically?


You must set ion-input control as touched.

Alternative: add manually html classes ion-touched ion-invalid to the ion-input.