Loading ...

Adding linebreaks in multiline textbox's text | CodeAsp.Net

Adding linebreaks in multiline textbox's text

 /5
0 (0votes)

Sometimes it is needed to add some text with linebreaks manually in textarea. It can be done by adding slash r and slash n (\r\n). Below is the sample code to do the same.

 

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <textarea id="myTextBox" style="width:500px;height:300px"></textarea>
    </form>
</body>
    <script type="text/javascript">
        var myTextBox = document.getElementById('myTextBox');
        var mytext='This is my text' +'\r\n'+
        'This is my text' + '\r\n' +
        'This is my text' + '\r\n' +
        'This is my text' + '\r\n' +
        'This is my text' + '\r\n';
        myTextBox.value = mytext;        
    </script>
</html>



 

Comments (no comments yet)

Top Posts