I formed a textarea
and a button that replaces the line breaks of this textarea
with <br />
tags.
Code:
var gtcontbtnafterTA = document.getElementById("contbtnafterTA");
var gtRequesttextarea = document.getElementById("Requesttextarea");
gtcontbtnafterTA.onclick = function(event) {
"use strict";
Requesttextarea.replace(new RegExp('\r?\n', 'g'), '<br/>');
}
#Requesttextarea {
font-family: Traditional Arabic;
font-size: 14pt;
color: #000099;
font-weight: bold;
text-align: center;
direction: rtl;
width: 80%;
height: 100px;
border: 3px double #FF0000
}
#contbtnafterTA {
font-family: Traditional Arabic;
font-size: 14pt;
color: #0000FF;
font-weight: bold;
width: 450
}
<p><textarea rows="50" name="Requesttextarea" cols="50" dir="rtl" id="Requesttextarea"></textarea></p>
<p><input type="button" value="الخطوات التالية" name="contbtnafterTA" dir="rtl" id="contbtnafterTA" class="buttonstyles"></p>
Resulting error:
Object doesn't support property or method replace
:
I hope I can get some code that replaces linebreaks with <br />
tags
Here are some pictures to explain the desired outcome.
Before:
After:
There is one line and some <br />
tags replacing each new line
tags?](https://stackoverflow.com/questions/784539/how-do-i-replace-all-line-breaks-in-a-string-with-br-tags) – treyBake Jun 11 '18 at 11:56
');` try this: `gtRequesttextarea.value.replace(new RegExp('\r?\n', 'g'), '
');` – r3dst0rm Jun 11 '18 at 11:56
');` – r3dst0rm Jun 11 '18 at 12:27