1

When I insert a value to my textbox I get a <br /> tag when I press Enter to insert a line break. How should I remove the <br /> tag and replace with a line break using jQuery.

$('#dbDocumentFooter').keyup(function(e){
    var TextToBeDisplayed = $(this).val();
    if(e.keyCode == 13 && !e.shiftKey)  {
        TextToBeDisplayed = $('#dbDocumentFooter').val().replace("\n", "<br />", "g")
        $('#dbDocumentFooter').val(TextToBeDisplayed);
    }    
});
Fizz
  • 3,427
  • 4
  • 27
  • 43

1 Answers1

0

Try this one https://jsfiddle.net/qa3q9w3r/

$('#dbDocumentFooter').keydown(function(e){
    if(e.keyCode == 13 && !e.shiftKey)  {
        e.target.value+="\n";
        e.preventDefault();
    }    
});