title: Trim value of input text is is NaN, for further calculation. JS only
body: <p>So I have two input text fields, and two option select fields, currency exchange calculator. The value from first input field and from two select options are used to calculate the final value.</p>
  
  <p>What I want to achieve is if user types in left input -- for example "20a" -- trim "a" or any other string and continue to calculate value.</p>
  
  <p>Thanks so much in advance. Here is my code:</p>
  
  <pre><code>function calculusSmaller(cur1, cur2) {
      calculatedCurrency.value = parseFloat(currVal * (cur1 / cur2)).toFixed(2);
  }
  
  function calculusBiger(cur1,cur2) {
      calculatedCurrency.value = parseFloat(currVal * (cur1 * cur2)).toFixed(2);
  }
  
  //adjusting values if empty or NaN
  
  if (!isNaN(placeholderCurrency.value)) {
      placeholderCurrency.parentNode.removeAttribute('data-error');
  }else {
      //HERE is the code needed, trimming the String.
      placeholderCurrency.parentNode.setAttribute('data-error', 'Please enter a number');
      mainCurrency();
  } 
  
  if (placeholderCurrency.value == "") {
      resetValues();
  }
  
  function mainCurrency(var1, var2) {
      var1 = firstValue;
      var2  = secondValue;
      switch(var1 + "|" + var2) {
          case "usd|rsd":
              calculusBiger(usd,rsd);
          break;
          case "eur|rsd":
              calculusBiger(eur,rsd);
          break;
          case "rsd|usd":
              calculusSmaller(rsd,usd);
          break;
          case "rsd|eur":
                  calculusSmaller(rsd,eur);
          break;
          case "eur|usd":
              calculusSmaller(eur,usd);
          break;
          case "usd|eur":
              calculusSmaller(usd,eur);
          break;
          default:
              resetValues();
      }
  
      console.log('test');
  }      
  
  mainCurrency();
  </code></pre>
  
  <p>And here is the HTML:</p>
  
  <pre><code>&lt;select name="selectedCurrency"&gt;
      &lt;option class="" data="0"  value="rsd"&gt;Rsd&lt;/option&gt;
      &lt;option class="" data = "2" value="eur" selected="selected" &gt;Eur&lt;/option&gt;
      &lt;option class="" data = "1" value="usd" &gt;Usd&lt;/option&gt;
  &lt;/select&gt;
  &lt;input value="1" type="text"  name="placeholder-currency"&gt;
  
  &lt;select name="currentCurrency"&gt;
      &lt;option class="" data="0" selected="selected" value="rsd"&gt;Rsd&lt;/option&gt;
      &lt;option class="" data="2" value="eur"&gt;Eur&lt;/option&gt;
      &lt;option class="" data="1" value="usd"&gt;Usd&lt;/option&gt;
  &lt;/select&gt;
  &lt;input type="text" value="1" name="calculated-currency"&gt;
  </code></pre>