title: setting maxlength using javascript
body: <p>I'm trying to set the maxlength on input fields dynamically using JavaScript. Apparently that is a problem in IE, and I found part of the solution.</p>
  
  <pre><code>$("input#title").get(0).setAttribute("max_length", 25);
  $("input#title").get(0).setAttribute(
                          "onkeypress", 
                          "return limitMe(event, this)");
  
  function limitMe(evt, txt) {
      if (evt.which &amp;&amp; evt.which == 8) return true;
      else return (txt.value.length &lt; txt.getAttribute("max_length");
  }
  </code></pre>
  
  <p>It works in Firefox, but not in IE for some reason. However, it works on input fields set like this:</p>
  
  <pre><code>&lt;input type="text" max_length="25" onkeypress="return limitMe(event, this);"/&gt;
  </code></pre>
  
  <p>But since the input fields are created dynamically, I can't do this... Any ideas?</p>