<script type="text/javascript">
function checking(textarea, maxLines, maxChar) {
var lines = textarea.value.replace(/\r/g, '').split('\n'), lines_removed, char_removed, i;
if (maxLines && lines.length > maxLines) {
lines = lines.slice(0, maxLines);
lines_removed = 1
}
if (maxChar) {
i = lines.length;
while (i-- > 0) if (lines[i].length > maxChar) {
lines[i] = lines[i].slice(0, maxChar);
char_removed = 1
}
if (char_removed || lines_removed) {
textarea.value = lines.join('\n')
}
}
}
</script>
This what I used based on few previous posts. But this code allows me to enter 'n' number of characters in 'm' number of lines. Could someone help me to write a code which takes only 30 characters and 2 lines? {suppose if the first line holds 10 characters then the next line should hold 20 characters but total number of characters should be 30 and lines to be 2.}