prevent writing in a textbox if table length exceeded
<p>so I'm using jquery tags input in my project i want to check if the user has entered more than the max allowed tags i should prevent him from writing how can i do that .
PS: i don't want to disable the input</p>

<p>that's my code so far : </p>

<pre><code>&lt;script type="text/javascript"&gt;
$(document).ready(function(){
$('#tag1').tagsInput({
'width':'300px',
'height':'50px',
'minChars' : 1,
'maxChars' : 12,
'onAddTag':tagsCountExceeded

});

function tagsCountExceeded(){

var TagsCount=2;
var TagsTable=$('#tag1').val().split(",");

$('#tag1').keypress(function(e){
if(TagsTable.length==TagsCount)
e.preventDefault();
});

}

 });
&lt;/script&gt;
</code></pre>

<p>but the keyPress function isn't working
    </p>
