Touched on form controls not working as expected


#1

Hi, after a recent update I have problem with form validation as the “touched” property does not work as expected.
For example:
<ion-item [class.error]="!email.valid && email.touched">
Email


<div ngIf=“email.hasError(‘required’) && email.touched” class=“error-box”> email is requred
<div ngIf=“email.hasError(‘pattern’) && email.touched” class=“error-box”> invalid email

What happens is that the form control is marked as touched as soon as the user starts entering. Previously, it was required that the control looses focus before it is marked as touched. Any help please.


#2

I just started using Ionic 3 and Angular 4 and bump into the same issue.
Ionic info prints:
cli packages: (/usr/local/lib/node_modules)
@ionic/cli-utils : 1.9.2
ionic (Ionic CLI) : 3.9.2

local packages:
@ionic/app-scripts : 2.1.3
Ionic Framework : ionic-angular 3.6.0

System:
Node : v8.4.0
npm : 5.3.0
OS : macOS Sierra


#3

I did not find any solution to this, I just reworked my forms to validate on submit, and to show validation errors on submit.


#4

@mitob
Can you please let me know how did you put validation on submit?