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 7624531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:59:18+00:00 2026-05-31T04:59:18+00:00

I am new to jquery & autocomplete, and am trying to learn them. The

  • 0

I am new to jquery & autocomplete, and am trying to learn them. The following works as I expect, except when someone types in something and hits ENTER. Then the textbox goes blank. How do I suppress this? I’d like it to trigger one of the existing events – select or change. Thanks,

<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Demo</title>
    <style>
      a.test { font-weight: bold; }
    </style>
  </head>
  <body>
    <link rel="stylesheet" type="text/css" href="css/ui-lightness/jquery-ui-1.8.18.custom.css">
    <link rel="stylesheet" type="text/css" href="css/autocomplete.css">
    <script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
    <script type="text/javascript" src="js/jquery-ui-1.8.18.custom.min.js"></script>
    <script>
      $(document).ready(function(){

            //attach autocomplete
            $("#suggest4").autocomplete({

                    //define callback to format results
                    source: function(req, add){

                            //pass request to server
                            $.getJSON("friends.php?callback=?", req, function(data) {

                                    //create array for response objects
                                    var suggestions = [];

                                    //process response
                                    $.each(data, function(i, val){
                                    suggestions.push(val.name);
                            });

                            //pass array to callback
                            add(suggestions);
                    });
            },

            //define select handler
            select: function(e, ui) {
                $("#spill").html("change "+ui.item.value+" "+e.type);
            },

            //define select handler

            change: function(e) {
                $("#spill").html("change "+$(this).val()+e.type);
            }

          });
      });
    </script>
    <div id="content">
      <form>
        <p>
          <label>Multiple Birds (local):</label>
          <input type="text" id="suggest4"></input>
        </p>
      </form>
    </div>
    <div id="spill">
    </div>
  </body>
</html>
  • 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-31T04:59:20+00:00Added an answer on May 31, 2026 at 4:59 am

    You need to bind to input keypress event, look for enter and then do what you want:

    $('#suggest4').keypress(function(e) {
         //catch only enter
         if(e.keyCode == 13) {
           e.preventDefault(); 
           //put your stuff in here
         }
      });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to incorporate jQuery autocomplete. It works fine with Firefox 3.6.. However
I've been trying to use the new jquery-ui, and all but the resizable function
Very new to JQuery and MVC and webdevelopment over all. I'm now trying to
Im new in jQuery so sure that i am doing something wrong :(. Matter
I am trying to use jQuery autocomplete on my dynamically created textboxes. this is
I am new to jQuery & I tried to resolve this on my own
I'm trying to make jQuery Autocomplete, Yahoo Finance and Zend Framework work together. What
I'm kinda new in jquery & ajax. I have 2 problems. I have the
The following jQuery autocomplete code is not displaying the results in MVC3. When I
am new to jquery! I'm using jquery ui autocomplete in my application where the

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.