title: Angular 2 form validation pattern regex error
body: <p>I'm creating a form in angular that requires the name field only contain alphanumeric characters and spaces. To do this I use the pattern attribute:</p>
  
  <pre><code>&lt;input type="text" class="form-control" placeholder="Name" name="Name" [(ngModel)]="name" required pattern="/^[a-z\d-_\s]+$/i" #nameField="ngModel"&gt;
  </code></pre>
  
  <p>and I have the following error message I want to show when the string does not match: </p>
  
  <pre><code>&lt;div *ngIf="nameField.errors"&gt;
     &lt;div [hidden]="!nameField.errors.pattern"&gt;
         &lt;p class="has-error"&gt;
            Only spaces, letters, and numbers are allowed.
         &lt;/p&gt;
     &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>However, it seems that even when the string should match the regular expression, I can still see the error message. Any ideas?</p>