title: How to limit the number of digits in number input?
body: <p>I am creating a form that will allow a user to enter a birthday with month, day and year. For year, I am trying to write the html code such that it will only allow positive number and also limit it to 4 digits. Here is the code in question:</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-html lang-html prettyprint-override"><code>&lt;input type="number" name="year" maxlength="4"  max="9999" min="0" step="1" placeholder="YYYY" p="[0-9]{4}" style="color:#888;" required/&gt; </code></pre>
  </div>
  </div>
  </p>
  
  <p>I've scoured the web for a solution to what I am trying to do but every time I try it, it will allow me to enter a number that is greater than 4 digits... basically I am trying to limit the user to enter a valid birth year:</p>
  
  <p>Any advice?? thanks in advance!!</p>
  
  <p><a href="https://i.stack.imgur.com/NLYT6.png" rel="nofollow noreferrer">Birth year greater than 4 digits input</a></p>