email input should be red like other input but is doesnt

34 views Asked by At

the input email like firs name and last name is invalid but the color on CSS dent match. I don't know what is a difference between this tow I change type of email to text but no direness the email input should be invalid but it doesn't

  ngOnInit(){
    this.reactiveForm=new FormGroup({
      firstname:new FormControl(null,Validators.required),
      lastname:new FormControl(null,Validators.required),
      email:new FormControl(null,[Validators.required]),
      country:new FormControl("iran"),
      gender:new FormControl("other"),
      hobbies:new FormControl(null),
    });
  }
2

There are 2 answers

0
Chuck Terry On

That's not a lot of information to go on, but you could try changing

email:new FormControl(null,[Validators.required]),

to

email:new FormControl(null,Validators.required),
0
giacomoto On

To validate an email add the Validators.email validator

{
    // other controls
    email:new FormControl(null, [Validators.required, Validators.email])
}

Also Angular adds the ng-invalid class to an input when invalid. If you have it, it's a css issue.