title: Limit html text input to a particular number of bytes?
body: <p>Using HTML5 (or less preferably JavaScript) is it possible to limit the maximum length of an <code>input</code> to a particular number of bytes?</p>
  
  <p>I realise that I can limit to a number of characters with:</p>
  
  <pre><code>&lt;input type="text" maxlength="4" /&gt;
  </code></pre>
  
  <p>But that's not good enough because I can input up to four two-byte chars in it.</p>
  
  <p>Obviously I am validating this server-side, but I would like this on the browser-side too.</p>
  
  <p><strong>Edit:</strong> Just to be clear, I do wish to be able to support UTF-8. Sorry @elclanrs.</p>