Saturday, November 12, 2022

Replacing line break before inserting to mysql

 

var input = document.getElementById("input").value;

if (!input)
{
// Null or undefined or bad input
alert("Invalid input");
}



// Replace line-breaks with "\n"
this.logData.description = input.replace(/(?:\r\n|\r|\n)/g, '\\n');

No comments:

Post a Comment