File tree 2 files changed +3
-2
lines changed 2 files changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ <h2>Registration Form</h2>
4
4
< form [formGroup] ="registrationForm ">
5
5
< div class ="form-group ">
6
6
< label > Username</ label >
7
- < input type ="text " formControlName ="userName " class ="form-control ">
7
+ < input type ="text " [class.is-invalid] =" registrationForm.get('userName').invalid && registrationForm.get('userName').touched " formControlName ="userName " class ="form-control ">
8
8
</ div >
9
9
10
10
< div class ="form-group ">
Original file line number Diff line number Diff line change 1
1
import { Component } from '@angular/core' ;
2
2
import { FormGroup , FormControl } from '@angular/forms' ;
3
3
import { FormBuilder } from '@angular/forms' ;
4
+ import { Validators } from '@angular/forms' ;
4
5
5
6
@Component ( {
6
7
selector : 'app-root' ,
@@ -21,7 +22,7 @@ export class AppComponent {
21
22
// });
22
23
23
24
registrationForm = this . fb . group ( {
24
- userName : [ '' ] ,
25
+ userName : [ '' , Validators . required ] ,
25
26
password : [ '' ] ,
26
27
confirmPassword : [ '' ] ,
27
28
address : this . fb . group ( {
You can’t perform that action at this time.
0 commit comments