Angular 7|8|9 Validate Mobile number With 10 Digits Example

Today, We want to share with you Angular 7|8|9 Validate Mobile number With 10 Digits Example.In this post we will show you phone number validation in angular 6 reactive form, hear for Angular 7,8,9 Form validations and custom validation, How to Implement we will give you demo and example for implement.In this post, we will learn about 10 digit mobile number validation in angular 6 with an example.

Angular 7|8|9 Validate Mobile number With 10 Digits Example

There are the Following The simple About 10 Digit Mobile Number Validation in Angular Full Information With Example and source code.

As I will cover this Post with live Working example to develop Validate phone number using angular js, so the 10 digit mobile number validation in angular 8 is used for this example is following below.

10 Digit Mobile Number Validation in Angular 2,6,7,8,9

List of all Google Adsense, VueJS, AngularJS, PHP, Laravel Examples.

src/app/app.component.html

<div class="bdy-cart container dsp">
    <h1>10 Digit Mobile Number Validation in Angular - pakainfo.com</h1>
      
    <form [formGroup]="form" (ngSubmit)="submit()">
          
        <div class="corona form-group lg10">
            <label for="mobileNumber">Mobile Number</label>
            <input 
                formControlName="mobileNumber"
                id="mobileNumber" 
                type="text" 
                class="form-control">
            <div *ngIf="f.mobileNumber.touched && f.mobileNumber.invalid" class="alert alert-danger">
                <div *ngIf="f.mobileNumber.errors.required">Mobile Number is required.</div>
                <div *ngIf="f.mobileNumber.errors.pattern">Please, Enter 10 digit Mobile Number.</div>
            </div>
        </div>
      
        <button class="btn btn-primary" type="submit" [disabled]="!form.valid">Submit</button>
    </form>

src/app/app.component.ts

import { Component } from '@angular/core';
import { FormBuilder, FormGroup, FormControl, Validators} from '@angular/forms';
   
@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  form: FormGroup = new FormGroup({});
  
  constructor(private fb: FormBuilder) {
    this.form = fb.group({
      mobileNumber: ['', [Validators.required, Validators.pattern("^((\+91-?)|0)?[0-9]{10}$")]]
    })
  }
    
  get f(){
    return this.form.controls;
  }
   
  submit(){
    console.log(this.form.value);
  }
   
}

Web Programming Tutorials Example with Demo

Read :

Another must read:  Angular 4 Grid with CRUD operations | Angular 4 insert update delete

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about mobile number validation in angular 7.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Reply

Your email address will not be published. Required fields are marked *