title: jquery - Autocomplete how to force select from list or user can type value from list and Submit form
body: <p>I have a form in which have one autocomplete text field and submit button. on Autocomplete text I have  below code which uses change event which basically empty out the text field if value is not part of the list, and on button- onSubmit i check if field is null or not, if its null then it displays error saying it can not be null.  All these work fine if I type in text and click somewhere else except submit button and then click on button. for eg. if I type xyzxyx  (which is not part of select list) on textbox and I click on submit button then it accepts whatever value is typed and takes it to next screen.  It seems like on OnSbumit event is firing first before onChange of Autocomplete field, how do i resolve this?</p>
  
  <pre><code>$(#testBox).autocomplete(
  {
  soruce: url,
  change:function(event,ui){
  if(ui.item=null)
  {
  $(#testBox).val('');
  alert("entered item is not part of the list");
  }
  }
  </code></pre>