Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The question is lacking specifics, but I will assume you mean validate on the client side since you referred explicitly to the auto complete plugin. This answer will have two parts. The first is the original answer, assuming one autocomplete plugin. The second is revised based on updates to the question.</p> <p>1) Using <a href="http://docs.jquery.com/Plugins/Autocomplete">http://docs.jquery.com/Plugins/Autocomplete</a></p> <p>The best solution for this is the "mustMatch" option. Here is the API <a href="http://docs.jquery.com/Plugins/Autocomplete/autocomplete#url_or_dataoptions">documentation</a>.</p> <blockquote> <p>If set to true, the autocompleter will only allow results that are presented by the backend. Note that illegal values result in an empty input box.</p> </blockquote> <p>You should be able to use it in this way:</p> <pre><code>$("selector").autocomplete("url", {"mustMatch": true}); </code></pre> <p>You can also validate the user input in some way in the "result" event. Here is a link: <a href="http://docs.jquery.com/Plugins/Autocomplete/result">http://docs.jquery.com/Plugins/Autocomplete/result</a> .</p> <p>2) Using <a href="http://jqueryui.com/demos/autocomplete">http://jqueryui.com/demos/autocomplete</a></p> <p>There is no mustMatch option here. You could extend the plugin, or you could add something similar to what I mentioned for the other autocomplete plugin. Use the "<a href="http://jqueryui.com/demos/autocomplete/#event-change">change</a>" event.</p> <pre><code>$( ".selector" ).autocomplete({ change: function(event, ui) { ... } }); </code></pre> <p>If you were using an array as a datasource, this would be more efficient. Since you are using a remote data source you would need to do another final query using ui.item to validate the user value. You can then allow or deny the default behavior.</p> <p>In either case, the input should still be validated in some way on the server side. This is out of the scope of jQuery plugins.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload