score:3

Accepted answer

Try this:

if(oInput.get(0).tagName == "TEXTAREA") {
    oInput.val(function(index, value) {
        return value.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '<br />');
    }
}

Similar question

score:0

Change the assignment to oInput.val(temp); i.e.

if(oInput.get(0).tagName == "TEXTAREA")
{
    temp = oInput.val();
    temp = temp.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '<br />');
    oInput.val(temp);
}

score:4

you can try

temp.replace(/\n/g,'<br/>');

second thing is, change oInput.val(temp);

fiddle : http://jsfiddle.net/yXhUV/


POPULA POST