title: Jquery autocomplete change source based on input value prefix
body: <p>I have 2 remote php scripts as data sources and I want to call each based on the user input prefix.
  I could not find how to do that with jquery autocomplete or with javascript.
  I will probably need to call a regex function to decide which data source to use.</p>
  
  <p>I am getting the user input from regular form text field:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
              jQuery(document).ready(function() {
                      $('#srv_search').autocomplete({
                              source:'srv_search.php',
                              minLength:2});
              });
      &lt;/script&gt;
              &lt;form action="site.php" method="post"&gt;
                      &lt;input type="text" id="srv_search" name="server" value="" style="width: 80%;"&gt;
                      &lt;input type="submit" value="Go"&gt;
              &lt;/form&gt;
  </code></pre>
  
  <p>Thanks,
  David</p>
  
  <p>PS, this is what I tried based on the reply and doesn't work:</p>
  
  <pre><code>$('#srv_search').autocomplete({
                              minLength:2,
                              source: function(request, response) {
                                      var usearch = request;
                                      var upatt = new RegExp(/^f[0-9]/);
                                      if (upatt.test(usearch)) {
                                              var dataSource = "srv_search.php";
                                      }
                                      else {
                                              var dataSource = "des_search.php";
                                      }
                                      $.get(dataSource, {term: request}, response);
                                      }
                      });
  </code></pre>