title: limit characters in input form with javascript
body: <p>I want to limit the number of characters from 3 to 10 in an input form. How can I manage it using Javascript. I need to do it with Javascript so I can change the input field border color from black to red when user's input doesn't meet the requirements. Here is my HTML code. I have tried some variants but got into a mess. Please provide me with the simple solution. Thanks beforehand.</p>
  <pre><code>&lt;form action=&quot;/index&quot; method=&quot;POST&quot;&gt;
    &lt;input type=&quot;text&quot; id=&quot;firstname&quot; name=&quot;firstname&quot; placeholder=&quot;First name&quot;&gt;
    &lt;br&gt;
    &lt;input type=&quot;text&quot; id=&quot;lastname&quot; name=&quot;lastname&quot; placeholder=&quot;Last name&quot;&gt;
  &lt;/form&gt;
  </code></pre>