views:

87

answers:

0

I'm trying to figure out how to get the jQuery Autocomplete plugin to handle a non-matching value. When there's a match, I'd like to submit the form (this part works) and when there isn't a match, I'd like to display an error message.

The if (data) part works. Shouldn't the 'else' portion of my if statement execute when a non-match is encountered?

Here's my code:

$("#input").autocomplete(data,{
  mustMatch: false,
  scroll: false,
  width: 212
}).result(function(event, data, formatted){
  if (data) {
    alert("match!");            
  } else {
    alert("no match!");
  }
}); 

Thanks! Moe