title: Validate zipcode to only allow length 5 or 7 digits in Angular 4
body: <p>I am using Angular 4. I want to allow the <code>zipCode</code> input field to only take an input of length 5 or 7 digits.</p>
  
  <p>HTML code:</p>
  
  <pre><code>&lt;md-input-container class="fill-width-input-wrap"&gt;
      &lt;input mdInput placeholder="Zip Code" formControlName="zipCode" minLength="5" maxLength="7" (keypress)="allowOnlyNumbers($event)" required&gt;
      &lt;md-error *ngIf="clientInformationForm.controls['zipCode'].hasError('required')"&gt;
          Please enter
          &lt;strong&gt;valid zipcode&lt;/strong&gt;
      &lt;/md-error&gt;
      &lt;md-error *ngIf="clientInformationForm.controls['zipCode'].hasError('minLength')"&gt;
          zip code
          &lt;strong&gt;minimum length is 5&lt;/strong&gt;
      &lt;/md-error&gt;
  &lt;/md-input-container&gt;
  </code></pre>