bug: form validation should not show red highlight until user has modified the field
See original GitHub issueBug Report
Ionic version:
[ ] 4.x [x] 5.x
Current behavior:
In reactive Angular forms, the ion-items within an ion-input, the highlights are marked in red when they have not yet been touched.
Expected behavior:
They should be blue until they are not touched, even though the validation of required giving an error.
Steps to reproduce:
Create a reactive form group and add the required validation
Related code:
import { ReactiveFormsModule } from '@angular/forms';
imports: [
ReactiveFormsModule,
...
],
formGroup: FormGroup;
constructor(public formBuilder: FormBuilder) {
this.formGroup = this.formBuilder.group({
text: [
"",
[Validators.required]
]
});
}
<form [formGroup]="formGroup">
<ion-item>
<ion-label floating>Text</ion-label>
<ion-input type="text" formControlName="text"></ion-input>
</ion-item>
</form>
Ionic info:
Ionic:
Ionic CLI : 6.10.1
Ionic Framework : @ionic/angular 5.2.2
@angular-devkit/build-angular : 0.1000.0
@angular-devkit/schematics : 8.3.25
@angular/cli : 10.0.0
@ionic/angular-toolkit : 2.2.0
Capacitor:
Capacitor CLI : 2.2.0
@capacitor/core : 2.2.0
Utility:
cordova-res : not installed
native-run : not installed
System:
NodeJS : v14.3.0
npm : 6.14.5
OS : Windows 10
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (3 by maintainers)
Top Results From Across the Web
bug: form validation should not show red highlight until ...
In reactive Angular forms, the ion-items within an ion-input, the highlights are marked in red when they have not yet been touched. Expected ......
Read more >Show red border for all invalid fields after submitting form ...
My question is after clicking on submit button i have to show red border for all the invalid fields. This is my form:...
Read more >Client-side form validation - Learn web development | MDN
When this attribute is set, the element matches the :required UI pseudo-class and the form won't submit, displaying an error message on ...
Read more >JavaScript: HTML Form - checking for non empty field
Often, situations arise when a user should fill a single or more than one field in an HTML form before they submit it....
Read more >Angular Reactive Forms: trigger validation on submit
We also do not display any validation error message. So the user have to guess that something is missing before the submit button...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks! That makes sense. I agree that this UX can be improved.
Our inputs should align more closely with this example: https://v7.material.angular.io/components/form-field/overview#error-messages. Specifically, the input should be highlighted blue when the user is initially editing the input, and then it should be red when the input is blurred and the validation fails.
Is there a workaround to use while we wait for this to be updated?