Sachin
Sachin

Reputation: 479

Jquery Autocomplete clear textbox if no match found

I am using Jquery's autocomplete plugins to show smart search textbox in my application.

To get better Idea plz refere following url

http://docs.jquery.com/Plugins/Autocomplete

Now what I want is, When user goes on typing in the textbox respected filter result get append to the textbox which is fine. If the user types character which doesn't match the result then I want to clear that character.

Means any how I want to force the user to type only those characters that are in the autocomplete result.

Thanks in advance.

Sachin

Upvotes: 2

Views: 8247

Answers (1)

Sachin
Sachin

Reputation: 479

$('#'+Artist.id).autocomplete(responce, { 
        matchContains:false, 
        minChars:1,  
        autoFill:false, 
        mustMatch:true, 
        cacheLength:20, 
        max:20 
    });

you can override .autocomplete(responce) with the one mention above and set the parameter as per your requirment.

The MustMatch=true solve my problem.

Upvotes: 2

Related Questions