0

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),
    });
  }
1
  • please include the html, or better, a stackblitz example Commented Sep 30, 2023 at 14:22

2 Answers 2

0

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),
Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.