title: Why is input pattern attribute not working for numerics?
body: <p>I can't get <a href="http://www.w3schools.com/tags/att_input_pattern.asp" rel="noreferrer">the pattern attribute</a> on a text input to be limited to numbers.  According to <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions" rel="noreferrer">the javascript regular expressions list</a>, [d] or [0-9] should do it.  But in </p>
  
  <pre><code>&lt;input dir="ltr" type="text" title="Enter numbers only." pattern="[\d]{9}" id="uid" name="1" placeholder="Enter UID" required="'required'" class="required placeholder" minlength="9" maxlength="9" autocomplete="off" /&gt;
  </code></pre>
  
  <p>it doesn't work for me (in any browsers).  I have to add js validation such as the following (decided to go this route for simplicity based on <a href="https://stackoverflow.com/questions/469357/html-text-input-allow-only-numeric-input">this post</a>):</p>
  
  <p>HTML:</p>
  
  <pre><code>onkeypress='return isNumberKey(event)' 
  </code></pre>
  
  <p>js:</p>
  
  <pre><code>function isNumberKey(evt){
      var charCode = (evt.which) ? evt.which : event.keyCode
      if (charCode &gt; 31 &amp;&amp; (charCode &lt; 48 || charCode &gt; 57))
          return false;
      return true;
  }
  </code></pre>
  
  <p>I mainly want to know if there's a way I can get the pattern attribute to work.  But also feel free to comment on whether I'm using best practices route for this.  I don't want to use HTML5 <code>&lt;input type="number"/&gt;</code> as it's not widely supported enough yet.</p>