title: How to run a function when Materialize.css autocomplete is not selected?
body: <p>I'm trying to write a function that will execute when the a Materialize.css autocomplete option is <em>not</em> selected. Is this possible? Basically I want to automatically add a value to an email field based on a user-selected autocomplete option in the name field, which works fine. But I would also like that email value to disappear when the user types in a custom name, and so far I can't get it to work without some kind of "clear" button. I've tried writing an if/else statement like this:</p>
  
  <pre><code>$('input.autocomplete').autocomplete({
    data: {
      //Data options
    },
    limit: 20, 
    onAutocomplete: function(val) {
      if ( $("#personname").val() == "last name, first" ) {
        $("#personemail").val("email@business.com");
      }
      else {
        $("#personemail").val("");
      }
    },
    minLength: 1, 
  });
  </code></pre>
  
  <p>But this doesn't appear to work because (I think) this function will only run if autocomplete has executed?</p>