title: How to validate a maximum input of characters with regex
body: <p>This should be simple, all I want to do is make an input field have a limit of 25 characters using regex.</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;&lt;!--
  function EnforceMaximumLength(fld,len) {
      if(fld.value.length &gt; len) { fld.value = fld.value.substr(0,len); }
  }
  //--&lt;/script&gt;
  
  &lt;form id="contact" &lt;%--action="contact.html" method="post"--%&gt;&gt;
        &lt;div class="form_settings"&gt;
          &lt;p&gt;&lt;span&gt;Name&lt;/span&gt;&lt;input class="contact" type="text"       onkeyup="EnforceMaximumLength(this,25)" name="your_name" value="" /&gt;&lt;/p&gt;
          &lt;p&gt;&lt;span&gt;Email Address&lt;/span&gt;&lt;input class="contact" type="text" onkeyup="EnforceMaximumLength(this,50)" name="your_email" value="" /&gt;&lt;/p&gt;
          &lt;p&gt;&lt;span&gt;Message&lt;/span&gt;&lt;textarea class="contact textarea" rows="5" cols="50" name="your_message"&gt;&lt;/textarea&gt;&lt;/p&gt;
          &lt;p style="padding-top: 15px"&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;input class="submit" type="submit" name="contact_submitted" value="send" /&gt;&lt;/p&gt;
        &lt;/div&gt;
      &lt;/form&gt;
  </code></pre>
  
  <p>What I have is some javascript deleting any characters over limit. </p>
  
  <p>How do you use regex to set a limit?</p>