I am trying to write a JS function that takes a block of text pasted inside textarea, removes line breaks but keeps paragraph breaks, and updates the text inside that textarea before I submit a form.
I have attempted to do it this way:
<textarea name="sum" id="sum" onpaste="frmt()"></textarea>
JS:
function frmt() {
const tar = document.getElementById("sum");
const reg = /[\r\n](?![\r\n])/g;
const str = tar.value;
tar.innerHTML = str.replace(reg, "");
}
What am I missing?