javascript - jquery autocomplete accept without selecting from dropdown -


im using autocomplete plugin show user options choose when typing word.

the problem here is:

this code won't allow word if user types correctly word match avaible tags without clicking on showed items on dropdown.

how can fix it?, have.

$( "#fuente" ).autocomplete({       source: availabletags,       change: function (event, ui) {             if (ui.item == null || ui.item == undefined) {                 $("#fuente").val("");                 $("#fuente").attr("disabled", false);                 $('#fuente').removeclass('fuenteboxcheck');                 $('#fuente').addclass('fuenteboxncheck');             }              else {                 $('#fuente').removeclass('fuenteboxncheck');                 $('#fuente').addclass('fuenteboxcheck');             }         }     }); 

is there easy way fix this?, pls halp. thnx.

ok.. did more research , found solution problem. hope helps else problem.

var lastvalue;          var lastvalue;          $("#fuente").autocomplete({           source: availabletags,           select: function(event, ui) {                 lastvalue = ui.item.value;             },           response: function(event, ui) {             //lastvalue = ui.content.length > 0 ? ui.content[0].value : '';             if(ui.content.length > 0){                 lastvalue = ui.content[0].value;                 $('#fuente').removeclass('fuenteboxncheck');                 $('#fuente').addclass('fuenteboxcheck');             }             else{                 lastvalue = '';                 $('#fuente').removeclass('fuenteboxcheck');                 $('#fuente').addclass('fuenteboxncheck');             }           }         });                    $("#fuente").on('blur', function() {             $(this).val(lastvalue);         });lse{                 lastvalue = '';                 $('#fuente').removeclass('fuenteboxcheck');                 $('#fuente').addclass('fuenteboxncheck');             }              }         });         $("#fuente").on('blur', function() {             $(this).val(lastvalue);          });       }); 

thnx.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -