$(document).ready(function(){
    $('#mesaj_text').keyup(function(){
        var max = parseInt($(this).attr('maxlength'));
        if($(this).val().length > max){
            $(this).val($(this).val().substr(0, $(this).attr('maxlength')));
        }

        $(this).parent().find('.charsRemaining').html((max - $(this).val().length) + ' caractere ramase');
    });
});
