JQuery Autocomplete verify selected value -
We are using the full jquery plugin, and are trying to enter valid options.
The result of the plugin () is the event which starts to fire after a selection is fine, but I need to check the value in the text box when a user even clicks. That's why we have tried the events of a .change () and .blur (), but they both generate a problem: when you click on an entry in the result div ('Suggestions' list) .change () and The fire of events .blur (), and before that the plugin has written a value in the text box, so there is nothing to verify at this point
Does anyone help me configure the event, Whenever someone clicks, but results Not in the box, I can check valid values in the box. If this is a wrong way, please tell me the correct one, we basically went with this plugin due to our 'match match' option. This option does not work in all cases. Many times a valid entry will be written in the textbox and after the plugin is cleaned as invalid, I will not be able to determine why.
Example of the original code:
& lt; Html & gt; & Lt; Top & gt; & Lt; Title & gt; Choose favorites & lt; / Title & gt; & Lt; Script language = "javascript" src = "jquery-1.3.2.min.js" & gt; & Lt; / Script & gt; & Lt; Script language = "javascript" src = "jquery.autocomplete.min.js" & gt; & Lt; / Script & gt; & Lt; Script & gt; $ ("Suggestions"). Autocomplete ("fetchNames.asp", {matchContains: false, minChars: 1, AutoFill: wrong, should match: wrong, cache length: 20, max: 20}); $ ("Suggestions"). Result (function (event, data, formatted) {var u = this; // check here}}; / * or * / $ ("suggestion"). Change (function (m) {// check value here }); & Lt; / script & gt; & lt; / head & gt; & lt; body & gt; label = "tbxName" for & gt; name (I'll show 10): & lt ; / Label & gt; & lt; INPUT type = "text" id = "tbxName" name = "tbxName" class = "suggestion" & gt; & lt; br / & gt;
I think To verify whether or not matches the data Instead of typing your function, you can just call search () . If the results () with a zero data parameter , You know that auto-complete was not used and on search () blur, you should get the result () at least once Guaranteed.
I posted this code, it can also help here.
Autocomplete files (function (event, data, formatted) {if (data) {// auto-matched // NB: this can be called twice, but it's okay Is) other {// should be triggered by search () // was not a match below}}); AutocompleteField.blur (function () {autocompleteField.search (); // trigger result () on stigma, even if it is not fully used}};
Comments
Post a Comment