title: Validation based on keypress in angular 2
body: <p>I am trying to do simple number validation for angular2 project. But I am unable to replicated JavaScript code written below.</p>
  
  <p>Html</p>
  
  <pre><code>&lt;input type="text" class="textfield" value="" id="extra7" name="extra7" onkeypress="return isNumber(event)" /&gt;
  </code></pre>
  
  <p>JavaScript</p>
  
  <pre><code>function isNumber(evt) {
      evt = (evt) ? evt : window.event;
          var charCode = (evt.which) ? evt.which : evt.keyCode;
  
          if (charCode &gt; 31 &amp;&amp; (charCode != 46 &amp;&amp; (charCode &lt; 48 || charCode &gt; 57))) {
              return false;
          } else {
              return true;
          }
  }
  </code></pre>
  
  <p>Now for angularJS2 when I tried to do <code>return isNumber(event)</code> it is unable to compile html file. And firing up Rx.js error. If I remove <code>return</code> it compiled but not work as it should. </p>
  
  <p>Am I missing something in terms of AngularJS2 world. </p>
  
  <p>Please let me know if any further details are required.</p>
  
  <p><strong>Update</strong>
  </p>
  
  <p>This way I am doing it in angular2. Here I can get keypress if I remove the return keyword but can't use whatever I am returning from isNumber method.</p>
  
  <p>PS: I am doing all this special work because Firefox input type number check for number at the time of Form post. And AngularJS2 is bypassing form post (full html post) to give ajax post afaik.  </p>