Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

135
Visualizações
How to detect manual entry or selection in Jquery AutoComplete

I have this jsfiddle for Jquery autocomplete

https://jsfiddle.net/fp7n8em5/

I want to identify , if the text inside the autocomplete field was a manual entry or a selected one from dropdown

when i was debugging this , i found out that the eventype is same for both that is autocompletechange

basically i need to clear some of the fields if its a manual entry and don't want to do it when its a selection

my code

$( "#tags" ).autocomplete({
source: availableTags,

  select : selectedOne,
  
  change: changedOne

});

function selectedOne()
{
alert('belongs to selectedOne')
}
function changedOne()
{
alert('belongs to changedOne')
}

});
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Can you differentiate the data coming from the external source? For example you can return an extra parmeter (ie: ID), or you can add a fixed parameter (ie: type = external). Then, when change fires, you test the returned object, if there is the parameter, then it comes from dropdown.

Or you can set input hidden variable and then you'll test if this variable is empty. Here is an example:

$( "#tags" ).autocomplete({
    source: availableTags,
    minLength: 2,
    select: function( event, ui ) {
        document.formname.input_type_hidden.value = ui.item.id;
    }
});
<form name="formname"><input type="hidden" name="input_type_hidden" value=""></form>
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda