Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

128
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!