Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7594945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:32:52+00:00 2026-05-30T21:32:52+00:00

I have a field accountname that uses Jquery autosuggest in a textbox. Here as

  • 0

I have a field “accountname” that uses Jquery autosuggest in a textbox. Here as the user selects from the autosuggestion values and press “Enter Key” to fill with the selected value.
Currently i have mapped “Enter Key” to submit the form using “Jquery hot keys” plugin.

problem is, as soon as the user selects value from autosuggest, if he presses “Enter” to select. form is getting submitted. I dont want to submit the form, when the user presses enterkey in autosuggest dropdown. But should submit the form when the focus is on autosuggest field.

Which function needs to be overridden?

Here is my Snippet:

$(document).ready(function() {  
         var availableTags = [
            // abbreviations                  
            {"label":"academy - acad","value":"acad"},{"label":"accident - acc","value":"acc"},{"label":"account - acct","value":"acct"}];

    function split( val ) {
        return val.split(/\s\s*/ );
    }

    function extractLast( term ) {
        return split( term ).pop();         
    }

    $("#accountName").bind( "keydown", function( event ) {
        if ( event.keyCode === $.ui.keyCode.TAB &&
                $( this ).data( "autocomplete" ).menu.active ) {
            event.preventDefault();
        }

    }).autocomplete({
        minLength: 2,
        autoFocus: false,

        source: function( request, response ) {             
            // delegate back to autocomplete, but extract the last term
            response( $.ui.autocomplete.filter(
                    availableTags, extractLast( request.term ) ) );
        },
        focus: function() {             
            // prevent value inserted on focus
            return false;
            //return false;
        },
        select: function( event, ui ) {             
            var terms = split( this.value );
            // remove the current input
            terms.pop();
            // add the selected item
            terms.push( ui.item.value );
            // add placeholder to get the comma-and-space at the end
            terms.push( "" );
            this.value = terms.join(" ");

            // added to trim space
            $("#accountName").val($.trim($("#accountName").val()));

            return false;
        }
    });
}); 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T21:32:53+00:00Added an answer on May 30, 2026 at 9:32 pm

    Stop the event propoagation on select event of autocomplete.

    $( ".selector" ).autocomplete({
       select: function(event, ui) {  
           event.stopPropagation();
       }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a field on my User model that is protected because it determines
I have field that it's not a key (it's text) and I want to
I have field X that contains text with spaces in the end of the
All of my datamodels have field DateAdded. When the user (through MVC Web API)
I have made customized user registration page. and i have made that on theme
i have field Tdate (text type) on my Table MyTbl i need query that
I have some tables which all have a field named created_at , that's a
using the below jquery placeholder plugin that creates labels and overlays the field with
I have a multipart form that takes basic user information at the beginning with
I have field in my Model which indicates whether a user wants to receive

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.