title: How to validate date in angular 4
body: <p>I ma new to angular ,In my application I need to validate a date and display span message based on validation .</p>
  
  <p>Here I am using ngx-bootstrap datepicker .</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;label for="mDOB" class="control-label"&gt;Date of birth&lt;/label&gt;
              &lt;input [bsConfig]="bsConfig"  type="text" maxlength="10" name="mDOB" [(ngModel)]="mUser.mDOB" #mDOB="ngModel"
                placeholder="Date of birth" class="form-control" bsDatepicker required&gt;
              &lt;div class="help-block alert-danger col-sm-12" *ngIf="mDOB.errors?.required &amp;&amp; mDOB.touched"&gt;
                * Date of Birth is required
              &lt;/div&gt;
  </code></pre>
  
  <p>Here I have done the reguired field validation .it's working fine </p>
  
  <p>Now I need to validate the date field accepts only numbers and format should be "mm/dd/yyyy".</p>
  
  <p>app.component.ts</p>
  
  <pre><code>submitForm(newUser: User): void {
  
      //  pattern="^(0?[1-9]|1[0-2])/(0?[1-9]|1[0-9]|2[0-9]|3[01])/\d{4}$";
      // newUser.mDOB using this I can get the selected date .
      // it always returns 2018-06-11T18:30:00.000Z in this format 
      // So here I need to convert from this format to "mm/dd/yyyy"
    }
  </code></pre>
  
  <p>Can anyone help me to solve this .</p>