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

  • Home
  • SEARCH
  • 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 6198205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:57:22+00:00 2026-05-24T03:57:22+00:00

In my form there is a textbox and submit button. When a user starts

  • 0

In my form there is a textbox and submit button. When a user starts typing, after the 3rd letter the autocomplete script does it’s magic.

There are two possibilities.

  1. The user types a word, there are matches and he clicks on one match. This selected match is added to the textbox and then hits the submit button.
  2. The user types a word, there/there are not matches but he decides to hit the submit button without selecting one of the suggested.

My question is how can I identify whether he hit the button in case 1 or in case 2.

rpc.php is the file that looks for suggested values through the mySQL.

A solution is to check the string if there is on the database but I do not want this.

Another solution is to transform the jQuery script and php code that shows the product name and instead of putting the product in the textbox, it should take him to the results page. This solves my problem also.

<script type="text/javascript">
$().ready(function() {

    $("#s").autocomplete("rpc.php", {
        width: 250,
        selectFirst: false,
        minChars: 3,
        scroll:true,
matchContains: true,

        scrollHeight: 250
    });

});
</script>

<form method="get" action=".php">
<input type="text" name="s" id="s" class="inputsearch">
<input type="submit">
</form>
  • 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-24T03:57:23+00:00Added an answer on May 24, 2026 at 3:57 am

    Use autocomplete’s change method to set a flag in the form, eg

    /// Create an hidden element to store the flag value,
    /// 1 for AC used, 0 for user entered
    var flag = $("<input>").attr("type", "hidden")
                           .attr("name", "ac_flag")
                           .val(0);
    
    // append flag to form
    $("form").append(flag);
    
    $("#s").autocomplete("rpc.php", {
        change: function(event, ui) {
            flag.val(ui.item != null ? 1 : 0);
        },
        // and the rest
    });
    

    The “change” event fires when the value in the text field changes. When an AC item is chosen ui.item will contain an object reference to the selected item from the list. If no selection was made, ie the user simply entered text, ui.item will be null.

    Your form handler can then check for $_GET['ac_flag'] to determine whether or not the value came from the autocomplete list.

    Quick mockup example here – http://jsfiddle.net/9GQgh/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any html form class(text box) that does not allow null values. The
Is there a way to use form fields that does not correspond to database
I have a personal simple jQuery validation script. It works when the submit button
i have a form with some textbox When a user press the enter key
one of the fields on my form is a textbox that the user types
A Submit button for a form located on my page triggers the code below,
This is a little form that I have that is a submit button a
There is one form, inside the form there are many checkboxes. Two operations can
Scenario I have a Windows Forms Application. Inside the main form there is a
I've created two UserControls, a ValidationManager and a ValidationOutput. On a given form there

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.