Count the maximun number of characters

Mar 10, 2010 at 5:28 PM

Hello,

I want to limt the maximun number of chars inside the textarea.

I tried to use the following code but don't work properly with jHtmlArea :

***********************************************

$(document).ready(function(){
        var    battute = 920;
        $('#textarea_intro').after("<p class='avviso'>Hai ancora <strong>"+ (battute - $('textarea').val().length)+"</strong> caratteri disponibili</p>");
            $('#textarea_intro').keyup(function(){
                if($(this).val().length > battute){
                    $(this).val($(this).val().substr(0, battute));
                }
                $(this).parent().find('p.avviso').html("Hai ancora <strong>"+ (battute - $(this).val().length)+"</strong> caratteri disponibili");
           });
    });
    **********************************************

Any ideas?

 

Thanks in advance,

Mirco