title: Remove Extra Spaces Before and After javascript string
body: <pre><code>var $one = $('#oneClueShow');
      var x = $("#clueOneInput").find('input[type=text]').val();
      if(x == 'D R' || x == 'd r'|| x == 'D r'|| x == 'd R'|| x == 'd'|| x == 'r' || x == 'd R' || x == 'T A')
  </code></pre>
  
  <p>Above is a snippet of java/ I have. What it does is takes an input  -- then checks for a match. The bug I'm looking to resolve is if there are spaces after or before it isn't recognized.</p>
  
  <p>For example within the input someone can type 'D R' no problem. If a space is added like so 'D R ' then it no longer recognizes the input.</p>
  
  <p>Is there something I can do to affect the input to ensure no space before/after prior to button click? I've been looking into replace, but can't seem to get it going.</p>
  
  <p>A reference for what I've been looking at : <a href="http://www.w3schools.com/jsref/jsref_replace.asp" rel="noreferrer">http://www.w3schools.com/jsref/jsref_replace.asp</a></p>