How can I limit the amount of characters between a newline?
I have a textarea that should only have 50 characters per line. I found a
way to automatically add a newline after a user has typed 50 characters
$('#textarea').keyup(function (e) {
if ($(this).val().length % 50 == 0 && $(this).val().length > 0) {
$(this).val($(this).val() + '\n');
}
})
but this doesn't cover text that is pasted into the textarea. How can I
simply prevent there from ever being more than 50 characters between every
'\n' in the textarea? In other words, I want to have a fixed limit of 50
characters per line.
No comments:
Post a Comment