Remove with click when enter many space and a new line

At textarea when write:

Its work with new line my problem still with many space after all to remove that? Can someone help me with .replace? So not just new lines also more than 2 spaces do not enter more. :slight_smile:

Thank you!

Can you provide an example of what a user might enter which has the issues you are wanting to deal with in your code? It would be great if you could show a before and after example, because I am having trouble understanding what you are trying to achieve here.

My guess based on your current code you are wanting to replace any new line character with a space character. If so, then you could use:

$('#c').click(function() {
  var currentText = $('#a').val();
  $('#a').val(currentText.replace(/\n/g, ' '));