Search code examples
angular6angular7

Reactive form email validation in angular 7


I am new in angular.Email validation is not working in my reactive form validation. I have an error somewhere, but I'm not sure what it is.

Script:

  this.loginForm = this.formBulder.group({

  fname:['', Validators.required],
  lname:['', Validators.required],
  email:['',  Validators.required],
  password:['', Validators.required,Validators.maxLength(5)],
  retypepassword:['', Validators.required,Validators.maxLength(5)]

  });

https://stackblitz.com/edit/angular-forms-validation-tfzhug?file=app/app.component.html


Solution

  • you can try this :

     this.loginForm = this.formBulder.group({
    
              'fname': new FormControl('',Validators.required),
               'lname': new FormControl('',Validators.required),
               'email': new FormControl('',[Validators.required,Validators.email]),
              'password': new FormControl('',[Validators.required,Validators.maxLength(5)]),
               'retypepassword': new FormControl('',[Validators.required,Validators.maxLength(5)]),
    
               });