Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<pre><code>(function () { var oldVal; $('#name').on('change textInput input', function () { var val = this.value; if (val !== oldVal) { oldVal = val; checkLength(val); } }); }()); </code></pre> <p>This will catch <code>change</code>, keystrokes, <code>paste</code>, <code>textInput</code>, <code>input</code> (when available). And not fire more than necessary.</p> <p><a href="http://jsfiddle.net/katspaugh/xqeDj/" rel="noreferrer">http://jsfiddle.net/katspaugh/xqeDj/</a></p> <hr> <p><strong>References:</strong></p> <p><a href="http://www.w3.org/TR/DOM-Level-3-Events/#event-type-textinput" rel="noreferrer"><code>textInput</code></a> — a W3C DOM Level 3 event type. <a href="http://www.w3.org/TR/DOM-Level-3-Events/#events-textevents" rel="noreferrer">http://www.w3.org/TR/DOM-Level-3-Events/#events-textevents</a></p> <blockquote> <p>A user agent must dispatch this event when one or more characters have been entered. These characters may originate from a variety of sources, e.g., characters resulting from a key being pressed or released on a keyboard device, from the processing of an input method editor, or resulting from a voice command. Where a “paste” operation generates a simple sequence of characters, i.e., a text passage without any structure or style information, this event type should be generated as well.</p> </blockquote> <p><code>input</code> — an <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/section-index.html#events-0" rel="noreferrer">HTML5</a> event type.</p> <blockquote> <p>Fired at controls when the user changes the value</p> </blockquote> <p>Firefox, Chrome, <a href="http://msdn.microsoft.com/en-us/library/gg592978%28v=vs.85%29.aspx" rel="noreferrer">IE9</a> and other modern browsers support it.</p> <blockquote> <p>This event occurs immediately after modification, unlike the onchange event, which occurs when the element loses focus.</p> </blockquote>
 

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