Page 1 of 1

Adding Carriage Returns via javascript in a TextArea box.

Posted: Wed Sep 04, 2013 9:28 am
by Andy Parker

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


Adding Carriage Returns via javascript in a TextArea box.

Posted: Wed Sep 04, 2013 11:11 am
by Anton Artyukh5836028

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


Adding Carriage Returns via javascript in a TextArea box.

Posted: Wed Sep 04, 2013 3:16 pm
by Andy Parker

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.