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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:08:08+00:00 2026-05-25T20:08:08+00:00

We have a jquery autocomplete input box: <input name=suburb id=suburb-agency autocomplete=off class=text type=text value=>

  • 0

We have a jquery autocomplete input box:

<input name="suburb" id="suburb-agency" autocomplete="off" class="text" type="text" value="">

This drops down, and when they choose an option, another select box is updated depending on what was chosen:

<select class="text" name="state" id="state-agency">
    <option value="notselected">Please select your state...</option>
    <option value="Apple">Apple</option>
    <option value="Pear">Pear</option>
</select>

Say for example they choose Pear in the #suburb-agency autocomplete, Pear is then selected automatically in #state-agency

That works perfectly.

The only problem I am having is jquery validation, when Pear is selected and the #state-agency box is changed, the validation doesn’t show, although it does if I manually select an option from the drop down box.

Here is my jquery:

/* STATE VALIDATION */
    $("#state-agency").change(function () {
        var state = $('#state-agency').val();
        if (state == "notselected"){
            $('#state-agency').css({"border-color":"#3399ff"});
            $('#state-err').html("You must choose which state you work in.").removeClass("success_msg").addClass("error_msg");
            return false;
        }else{
            $('#state-agency').css({"border-color":"#1f6d21"});
            $('#state-err').html("Thanks for choosing your state!").removeClass("error_msg").addClass("success_msg");
        }
    });

How can I modify this so it shows the success message if it is selected from the autocomplete? and not just manually? I’m guessing I need to change from a change function?

Edit (our autocomplete code which updates the dropdown box as requested)

$(function() {
    function split( val ) {
        return val.split( /,\s*/ );
    }
    function extractLast( term ) {
        return split(term).pop();
    }

    $( "#suburb-agency" )
        // don't navigate away from the field on tab when selecting an item
        .bind( "keydown", function( event ) {
            if ( event.keyCode === $.ui.keyCode.TAB &&
                    $( this ).data( "autocomplete" ).menu.active ) {
                event.preventDefault();
            }
        })
        .autocomplete({
            source: function( request, response ) {
                $.getJSON( "http://www.site.com/folder/script.php", {
                    term    :   extractLast( request.term )
                }, response );
            },
            search: function() {
                // custom minLength
                var term = extractLast( this.value );
                if ( term.length < 2 ) {
                    return false;
                }
            },
            focus: function() {
                // prevent value inserted on focus
                return false;
            },
            select: function( event, ui ) {
              if (ui.item) {
                $('#state-agency').val(ui.item.state);
              }
              else {
                $('#state-agency').val('');
              }
            }
        });
});
  • 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-25T20:08:09+00:00Added an answer on May 25, 2026 at 8:08 pm

    I’ve found a fix for this, I needed to use trigger() on the relevent IDs in the autocomplete JS.

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

Sidebar

Related Questions

I have inputbox like this: <input type=text id=namecity1 name=city1 /> <input type=hidden id=idcity1 name=idcity1
I am using this jQuery UI combobox autocomplete control out of the box off
I have an input box for which I am using the Jquery autocomplete function.
I have a jQuery text box autocomplete script which uses a PHP script to
I have used the jquery-ui to autocomplete an input box and set a hidden
I have an input box for searching employee info (attached to a jquery autocomplete),
I have this code : #bottom-div { z-index:999 } <input type=text id=main /> <div
I have a jQuery UI Dialog Box that contains a jQuery UI Autocomplete input
using jquery I have a autocomplete text box like the combobox example on the
I have a jQuery autocomplete input box for time. It lists all available times

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.