skip to Main Content

I am trying to make a normal input, but if I write inside the input for example

text line1 text line1 
text line2 
text line3 text line3 

the value that i get : text line1 text line1 text line2 text line3 text line3

I tried textArea and normal input, and both of them gave me the same result.

2

Answers


  1. Chosen as BEST ANSWER
    var formattedInput = inputText.replace(/n/g, "<br>");
    

  2. Hello to retrieve the value of your textarea taking into account the lines

    we have our textarea tag
    <html><body><textareaname="textA"id="inputD" cols="30" rows="10" onchange="changeText()" </textarea> </body> </html>

    here is the js

    <script>
        function changeText(){
            var data = document.getElementById("inputD");
            var res = data.value; // res contain the value of your texarea
        }
    
    </script>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search