Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In gecko (e.g. firefox) the browser prevents that the value becomes longer if you use the <code>maxlength</code> attribute, so the <code>tooLong</code> validation variable will ever be <code>false</code> (see <a href="https://developer.mozilla.org/en/DOM/ValidityState" rel="nofollow">here</a>). There is no chance to hook there.<br> But you can use the <code>pattern</code>-attribute instead:</p> <pre><code>&lt;input ... pattern="^.{0,max}$" /&gt; </code></pre> <p>Replace <code>max</code> in the <code>pattern</code> regex with the number of maximum allowed characters.<br> Now you can bind the <code>input</code>-event and check the boolean <code>element.validity.patternMismatch</code> if the value is to long.</p> <p>Here are links to two examples I've created for you; they are tested with the current versions of firefox and chrome, I can't test with IE9:</p> <ul> <li><a href="http://jsfiddle.net/S4Sq4/" rel="nofollow">first example</a>: if the value is to long, it will be cut and for one second an error message will be shown; a small disadvantage is that you can see the input in a fraction of a second.</li> <li>in the <a href="http://jsfiddle.net/cPXCc/" rel="nofollow">second example</a> the value will never be changed, an error message will be shown until the number of characters is correct and you can only submit the form if all fields are valid.</li> </ul> <p>=== UPDATE ===</p> <p>For IE7 and IE8 support I have updated the examples:</p> <ul> <li><a href="http://jsfiddle.net/S4Sq4/3/" rel="nofollow">example1</a></li> <li><a href="http://jsfiddle.net/cPXCc/11/" rel="nofollow">example2</a></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload