Skip to content
Related Articles
Open in App
Not now

Related Articles

How to check whether a form or a control is valid or not in Angular 10 ?

Improve Article
Save Article
  • Difficulty Level : Basic
  • Last Updated : 03 Jun, 2021
Improve Article
Save Article

In this article, we are going to check whether a form is touched or not in Angular 10. The valid property is used to report that the control or the form is valid or not.



Return Value:

  • boolean: the boolean value to check whether a form is valid or not.

NgModule: Module used by the valid property is:

  • FormsModule



  • Create the Angular app to be used.
  • In app.component.html make a form using ngForm directive.
  • In app.component.ts get the information using the valid property.
  • Serve the angular app using ng serve to see the output.



import { Component } from '@angular/core';
import { FormGroup, FormControl, 
    FormArray, Validators } from '@angular/forms'
    selector: 'app-root',
    templateUrl: './app.component.html'
export class AppComponent {
    form = new FormGroup({
        name: new FormControl(
        rollno: new FormControl()
    get name(): any {
        return this.form.get('name');
    onSubmit(): void {
        console.log("Form is valid : ", this.form.valid);


<form [formGroup]="form" (ngSubmit)="onSubmit()">
    <input formControlName="name" placeholder="Name">
    <button type='submit'>Submit</button>


Reference: >

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!