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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:15:32+00:00 2026-05-27T15:15:32+00:00

I have a jQuery UI Dialog Box that contains a jQuery UI Autocomplete input

  • 0

I have a jQuery UI Dialog Box that contains a jQuery UI Autocomplete input box populated with various labels. The dialog box itself has two buttons in the buttonpane: “Select” and “Cancel.” However, I want enable and disable the “Select” button depending upon what the user has currently in the text field of the input box. In other words, the list of available tags that the autocomplete makes use of contains all of the valid options the user can select. So, if they select one of these labels from the autocomplete, the “Select” button will be enabled, allowing them to click it. In addition, if they simply type in the proper label without physically selecting one of the labels from the autocomplete’s drop-down box, I still want this “Select” button enabled.

At first, I figured I’d just cross-reference the text currently in the input box each time the input field changed with the list of available labels to see if I should enable the “Select” button, but so far, it hasn’t seemed to work. Any suggestions as to how I might accomplish this? Here’s what I’ve tried thus far:

$("#dialog").dialog({
    autoOpen: false,
    buttons: {
        Select: function() {
            // Carry out some proceedure knowing they've selected a valid label.
        },
        Cancel: function() {
            // Cancels the selection and closes the dialog box.
        }
    },
    closeOnEscape: false,
    create: function(event, ui) {
        var labels = ["Bird", "Boar", "Dog", "Dragon", "Ox", "Tiger"];
        $("#input").autocomplete({
            delay: 0,
            source: labels
        });
        $("#input").change(function() {
            $(".ui-dialog-buttonpane button:contains('Select')").button("disable");
            labels.each(function() {
                if($("#input").text() == $(this)) {
                    $(".ui-dialog-buttonpane button:contains('Select')").button("enable");
                    return;
                }
            });
        });
    },
    draggable: false,
    modal: true,
    resizable: false,
    title: "Select Dialog",
    width: 460
});
  • 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-27T15:15:33+00:00Added an answer on May 27, 2026 at 3:15 pm

    You were close, how about using $.inArray to toggle the button? Also, you need to use $(this).val() or this.value to figure out the value of an input element.

    $("#dialog").dialog({
        autoOpen: false,
        buttons: {
            Select: function() {
                // Carry out some proceedure knowing they've selected a valid label.
            },
            Cancel: function() {
                // Cancels the selection and closes the dialog box.
            }
        },
        closeOnEscape: false,
        create: function(event, ui) {
            var labels = ["Bird", "Boar", "Dog", "Dragon", "Ox", "Tiger"];
            $("#input").autocomplete({
                delay: 0,
                source: labels
            });
            $("#input").change(function() {
                var enabled = $.inArray(this.value, labels) >= 0 ? "enable" : "disable";
                $(".ui-dialog-buttonpane button:contains('Select')").button(enabled);
            });
        },
        draggable: false,
        modal: true,
        resizable: false,
        title: "Select Dialog",
        width: 460
    });
    

    Example: http://jsfiddle.net/kcrBB/


    Per the comment, here’s an example with keyup instead of change:

    $("#dialog").dialog({
        open: function () {
            $(".ui-dialog-buttonpane button:contains('Select')").button("disable");
        },
        buttons: {
            Select: function() {
                // Carry out some proceedure knowing they've selected a valid label.
            },
            Cancel: function() {
                // Cancels the selection and closes the dialog box.
            }
        },
        closeOnEscape: false,
        create: function(event, ui) {
            var labels = ["Bird", "Boar", "Dog", "Dragon", "Ox", "Tiger"];
            $("#input").autocomplete({
                delay: 0,
                source: labels,
                select: function () {
                    $(".ui-dialog-buttonpane button:contains('Select')").button("enable");       
                }
            });
    
            $("#input").keyup(function() {
                var enabled = $.inArray(this.value, labels) >= 0 ? "enable" : "disable";
                $(".ui-dialog-buttonpane button:contains('Select')").button(enabled);
            });
        },
        draggable: false,
        modal: true,
        resizable: false,
        title: "Select Dialog",
        width: 460
    });
    

    Example: http://jsfiddle.net/kcrBB/16/

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

Sidebar

Related Questions

I have a simple jQuery dialog box that has an html input inside it.
I want to raise a jQuery Dialog box which has 2 buttons. So that
I have a simple Jquery dialog box, that dialog contains a button which sends
I have a problem with the jquery-ui dialog box . The problem is that
I have a jquery dialog box that is used to edit and update a
I have a JQuery dialog box on a page that calls something like this:
I have a jQuery UI Dialog box, that I'm creating. It starts out as
I have a jQuery dialog box that opens and then an AJAX call is
I have some JQuery that pops up a JQuery Dialog ( http://docs.jquery.com/UI/Dialog ) box
I have a div, divDialog, that contains a simple dialog box. It begins life

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.