i need functionality that every character after 5th line in textarea will get deleted , and 5th line will only contain max 15 chars.
i can achieve this little bit using "caret", but it will only add text at particular cursor position, i m using kepress event and setinterval (onFocus of textarea) function which will clear extra text from textarea, and clearInterval (onBlur of textarea)
function insertTextAtCaret(el, text)
{
var val = el.value, endIndex, range;
if (typeof el.selectionStart != "undefined" && typeof el.selectionEnd != "undefined") {
endIndex = el.selectionEnd;
el.value = val.slice(0, endIndex) + text + val.slice(endIndex);
el.selectionStart = el.selectionEnd = endIndex + text.length;
} else if (typeof document.selection != "undefined" && typeof document.selection.createRange != "undefined") {
el.focus();
range = document.selection.createRange();
range.collapse(false);
range.text = text;
range.select();
}
}