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

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.

Read Also:  react open url in new tab ReactJS - Router

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

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 :

Read Also:  Angular 6 Form Validation with Message - Angular 6 Live Validation

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.


Related FAQ

Here are some more FAQ related to this Article:

  1. Read Also:  PHP Get domain name from full URL with parameters
  2. Read Also:  WordPress AJAX URL GET POST Call PHP Function
  3. Read Also:  Angularjs multiple Check and uncheck all checkbox
  4. Read Also:  WordPress HTTP API Remote Requests with wp_remote_get()
  5. Read Also:  Radio button Component in VueJS
  6. Read Also:  Hello World Example using Laravel MVC
  7. Read Also:  Confirm password validation in Angular 6|7|8|9
  8. Read Also:  Angular 6 CRUD Tutorial Example From Scratch
  9. Read Also:  Ajax File Upload without refreshing using jQuery and PHP
  10. Read Also:  Angular 9/8 Decimal Pipe Percent Pipe and Currency Pipe Example

Leave a Comment

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