How to replace whitespaces using javascript?
<p>I'm trying to remove the whitespaces from a textarea . The below code is not appending the text i'm selecting from two dropdowns. Can somebody tell me where i'd gone wrong? I'm trying to remove multiple spaces within the string as well, will that work with the same? Dont know regular expressions much. Please help.</p>

<pre><code>    function addToExpressionPreview() {
  var reqColumnName = $('#ddlColumnNames')[0].value;
  var reqOperator = $('#ddOperator')[0].value;

  var expressionTextArea = document.getElementById("expressionPreview");

  var txt = document.createTextNode(reqColumnName + reqOperator.toString());
  if (expressionTextArea.value.match(/^\s+$/) != null)
  {
    expressionTextArea.value = (expressionTextArea.value.replace(/^\W+/, '')).replace(/\W+$/, '');

  }
  expressionTextArea.appendChild(txt);
}
</code></pre>
