Я создал код, смотрящий на то, сколько символов помещается в ширину и высоту текстового поля, и установил максимальную длину текстового поля на основе этого числа
$('.textareaClass').keypress(function(){
let width = $(this).css('width').replace(/[^-\d\.]/g, ''); //getting the width of textarea
let height = $(this).css('height').replace(/[^-\d\.]/g, '');//getting the height of textarea
let widthchar = Math.floor(parseInt(width) / 7.5);//based on the width howmuch characters fit sideways
let heightchar = Math.floor(parseInt(height) / 15);//based on the height, howmuch lines of characters are there
let totalchar = widthchar * heightchar; //multiply lines by chars sideways to get a total amount of chars
$(this).attr('maxlength',totalchar);//setting the total as total for the text area
$(".char").html('you are allowed to type:'+ totalchar+'character(s)');//output to see howmuch you can type, just for debug/programming reasons to see what's happening
});
.textareaClass {
height:100px;
width: 50px;
resize: none;
overflow: hidden
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<textarea class="textareaClass"></textarea>
<div class="char">
</div>