title: Find if text is selected for input type number
body: <p>I have an <code>&lt;input type="number"</code> which can store maximum two digits. This is achieved by using <code>event.preventDefault();</code>. </p>
  
  <pre><code>function allowMaxNumbers(element, event, maxLength){
  if(element.value.length==maxLength&amp;&amp; event.keyCode!=8 &amp;&amp; event.keyCode!=46 &amp;&amp; event.keyCode!=9){
      if (event.preventDefault){
          event.preventDefault();
      }    
      return false;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>If user selects the input and types in another number, the new number should be inputted replacing the old input. Is there a way in javascript/jQuery to find if some text is selected in the input? </p>
  
  <p>I followed the question <a href="https://stackoverflow.com/questions/5001608/how-to-know-if-the-text-in-a-textbox-is-selected">How to know if the text in a textbox is selected?</a> and tried <code>input.selectionStart</code> and  <code>input.selectionEnd</code> but that is not working for <code>input type="number"</code></p>