 <p>HTML5 solution, min 5, max 10 characters</p> <p><strong><a href="http://jsfiddle.net/xhqsB/102/" rel="nofollow">http://jsfiddle.net/xhqsB/102/</a></strong></p> <pre><code>&lt;form&gt; &lt;input pattern=".{5,10}"&gt; &lt;input type="submit" value="Check"&gt;&lt;/input&gt; &lt;/form&gt; </code></pre>