title: Allowing only numbers from paste without using input number in pure JavaScript
body: <p>Before you read furtherly, look at my answer and Priyal Pithadiya answer for two different methods on how you can do this.</p>
  
  <p>I have a client that is not satisfied with the solution I got from yesterdays answer on here. Basically I have this script that prevents non number characters from being inserted in an <code>input</code>. It works perfectly when you type but I have a problem here I cannot figure out how to prevent non numbers from being pasted in. </p>
  
  <p>My client has stated that he want to avoid using <code>input number</code> since that was the solution that was offered here but for personal reasons he said he needs to use <code>input text</code>.</p>
  
  <p>If I have to change my code to get a result like this I will.</p>
  
  <p>Please note, I cannot use jQuery, my solution must be javascript only.</p>
  
  <p>This is my code:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>//Prevent non numbers from keypress 
  document.querySelector('#numbers-only').addEventListener('keypress',preventNonNumbersInInput);
  
  function preventNonNumbersInInput(event){
  
    var characters = String.fromCharCode(event.which);
  
    if(!(/[0-9]/.test(characters))){
      event.preventDefault();
    }
  
  }
  
  //Prevent non numbers from being pasted only numbers can be pasted
  document.querySelector('#numbers-only').addEventListener('paste',pasteTest);
  function pasteTest(){
    //???
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;input type="text" id='numbers-only'&gt;</code></pre>
  </div>
  </div>
  </p>