This project has moved. For the latest updates, please go here.

Count the maximun number of characters

Mar 10, 2010 at 5:28 PM


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 :


        var    battute = 920;
        $('#textarea_intro').after("<p class='avviso'>Hai ancora <strong>"+ (battute - $('textarea').val().length)+"</strong> caratteri disponibili</p>");
                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,