title: Angular 2: Number validation with Regex
body: <p>I'm trying to validate the number field in IE 11.</p>
  
  <pre><code>&lt;input type="number" name="amount" [(ngModel)]="amount" (keypress)="validateNum($event) /&gt;
  </code></pre>
  
  <p>And in typescript</p>
  
  <pre><code>private validateNum(event: KeyboardEvent): void {
      const pattern = /^\d{1,3}[.]\d{1,6}$/g;
      let inputChar = String.fromCharCode(event.charCode);
      if(!pattern.test(inputChar)) {
          event.preventDefault();
      }
  }
  </code></pre>
  
  <p>Here I'm trying to restrict the input to 3 digits and 5 decimals. The problem I'm facing is, regEx is validating for each key pressed (Not validating after the 3 digits pressed) and it is not allowing to enter any number. How do I validate the number after the numbers reach the restriction? Or is it possible to validate without regEx in Angular2?? I'm new to Angular and need suggestion.</p>