Home Angular7 Angular 7 Form Validation Methods for Different Input Fields

Angular 7 Form Validation Methods for Different Input Fields

by therichpost
0 comments
angular7

Hello to all, welcome to therichpost.com. In this post, I will tell you, Angular 7 Form Validation Methods for Different Input Fields.

If you are new in Angular 7, then please check old posts related to Angular 7.

In this post, I will give you tell some form input fields validations tricks In Angular 7.

ngOnInit() {
          this.formdata = new FormGroup({
                 //Number Validations and Min Max Validation
        	mobile_number : new FormControl("", [Validators.required, Validators.pattern("^[0-9]*$"), Validators.minLength(6), Validators.maxLength(10)]),

                 //Email Validation
        	email : new FormControl("", [Validators.required, Validators.email]),

                //Min lenght Validation
        	password : new FormControl("",  [Validators.required, Validators.minLength(5)]),

                //Empty Field Validation
        	package_type : new FormControl("", Validators.required),

       });

   
  }

 

For more information, please comment below or ask questions.

Harjas,

Thank you

You may also like

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.