I use the function below to control the maximum row of textarea.
<textarea wrap="hard" name="" class="jua" onkeydown="return limitLines(this, event)" id="text_01_01" rows="2" placeholder=""></textarea>
function limitLines(obj, e){
console.log("test");
let numberOfLines = (obj.value.match(/\n/g) || []).length + 1;
let maxRow = obj.rows;
if (e.which === 13 && numberOfLines === maxRow){
return false;
}
}
but this way, this method cannot detect line breaks by width. I want to count even rows that automatically wrap.
Sorry for my poor English skills. Thanks