title: How to show validation on button click in typescript
body: <p>I want to show up validation for the fields which are empty and for that i used the following method but its not working.Can anyone suggest me help.Thanks.</p>
  
  <p>My template,</p>
  
  <pre><code>&lt;form [formGroup]="form" (ngSubmit)="onSubmit(form.value)" class="nobottommargin adminloginform" novalidate&gt;
  &lt;label class="col-sm-4 text-right norightpadding"&gt;First Name&lt;/label&gt;
       &lt;div class="input-group" [ngClass]="{errmsg: (!form.controls['password'].valid ||
     (!form.controls['password'].pristine &amp;&amp; submitted ))}"&gt;
      &lt;input type="text" [formControl]="form.controls['lastname']" &gt;
    &lt;/div&gt;
  &lt;div class="col-sm-8"&gt;
            &lt;button type="submit" &gt;Register now&lt;/button&gt;
          &lt;/div&gt;
  </code></pre>
  
  <p>My ts,</p>
  
  <pre><code>    export class SignUp {
      submitted: boolean = false;
  constructor(public fbld: FormBuilder, http: Http, public config: Config, public router: Router) {
      this.http = http;
      this.form = fbld.group({
          firstname: ['', Validators.required],
      });
      this.header = this.config.header1;
  }
      onSubmit(form: ISignup): any {
          this.submitted = true;
       }
      }
  </code></pre>