title: Check dropdown options and do something while typing in input text box
body: <p>Having trouble with this function. I can only make it work for the last dropdown option in select box. In other words, it only does what it's supposed to do if I type the text of the last option in select box. It doesn't recognize that I typed the other options. I do an alert in the each loop and it shows me all the options, and i also alert what i type in. It should work for all the options, but it's not. Trying to add or remove class on the text input box. If i type one of the options add error class. If i change what i type and it doesn't match any of the options, remove error class.</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;select id="select" class="select selectpicker input-block-level" name="select"&gt;
      &lt;option value=""&gt;pick a thing&lt;/option&gt;
      &lt;option value="0.00"&gt;#1 thing&lt;/option&gt;
      &lt;option value="0.01"&gt;1x1 thing&lt;/option&gt;
      &lt;option value="0.02"&gt;some thing&lt;/option&gt;
      &lt;option value="0.03"&gt;something&lt;/option&gt;
      &lt;option value="0.04"&gt;thing&lt;/option&gt;
  &lt;/select&gt;
  
  &lt;input id="text" class="span12" type="text" placeholder="type a thing" value="" name="text"&gt;
  </code></pre>
  
  <p>JS:</p>
  
  <pre><code>function getValue() {
      var theValue = $('#text').val();
      //alert(theValue);
  
      //begin tried and failed stuff
      //var exists = 0 != $('#select option[text='+thevalue+']').length;
      //if($('#select option[text='+thevalue+']').length &gt; 0)
      //if(exists == true)
      //{
          //alert("exists");
          //$("#text").addClass("error");
      //} else {
          //$("#text").removeClass("error");
      //}
      //end tried and failed stuff
  
      $('#select option').each(function(){
          var theDropValue = this.text.toLowerCase();
          //alert (theDropValue);
          var theNewValue = theValue.toLowerCase();
          if (theDropValue == theNewValue) {
              //exists = true;
              $("#text").addClass("error");
          } else {
              $("#text").removeClass("error");
          }
      });
  }
  
  $(document.body).on( "change keyup input", "#text", function() {
      getValue();
  });
  </code></pre>