Andy Parker
Posts: 0
Joined: Wed Mar 27, 2013 10:21 am

Adding Carriage Returns via javascript in a TextArea box.

Hi,

I have a text-area where users can write a message.

I need to append some information to this message upon completion - which isn't a problem.

The issue I can't seem to sort is inserting some carriage returns so the additional text appears a couple of lines after the user text.

I've tried inserting "\n\r" but this just seems to disappear, any idea?

many thanks

Andy

Anton Artyukh5836028
Posts: 0
Joined: Wed May 08, 2013 12:57 pm

Adding Carriage Returns via javascript in a TextArea box.

Hi Andy,

Textarea doesn't support control character or non-printing character (\n or \r). It works with html-code. For example, you can add break line (like \n) with code like this: pre$('#TextareaBox')&#46;append('<br &#47;>');/pre

Andy Parker
Posts: 0
Joined: Wed Mar 27, 2013 10:21 am

Adding Carriage Returns via javascript in a TextArea box.

thanks for this, unfortunately it didn't give the expected results.

However, I've managed to sort it by using the code below:

var message = Tiggzi('messagebox');
var message1 = message + String.fromCharCode(13) + String.fromCharCode(13) + 'message ends here'
Tiggzi('messagebox').val(message1);

This inserts the 2 blank lines I needed.

Many thanks

Andy.

Return to “Issues”