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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:42:39+00:00 2026-05-27T10:42:39+00:00

UPDATE: Added the textEquals selector code. I am using jquery and autocomplete for a

  • 0

UPDATE: Added the textEquals selector code.

I am using jquery and autocomplete for a field in my web application.

I have a “change” event that ensures the user chose a valid value from the autocomplete list. This event works great except when there are parentheses in the chosen value the li:textequals selector does not work.

How do I escape the parentheses in the text that I’m searing for with li:textequals?

    change: function (event, ui) {
        //if the value of the textbox does not match a suggestion, clear its value             
        if ($(".ui-autocomplete li:textEquals('" + $(this).val() + "')").size() == 0) {
            $(this).val('');
        };

textEquals selector code:

$.expr[':'].textEquals = function (a, i, m) {
    return $(a).text().match("^" + m[3] + "$"); 
};
  • 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-27T10:42:39+00:00Added an answer on May 27, 2026 at 10:42 am

    I haven’t tested this, but the jQuery docs suggest two backslashes:

    If you wish to use any of the meta-characters ( such as !"#$%&'()*+,./:;<=>?@[\]^{|}~ ) as a literal part of a name, you must escape the character with two backslashes: \. For example, if you have an element with id="foo.bar", you can use the selector $("#foo\\.bar").

    So in your case it might need to be:

    var val = $(this).val()
        .replace("(", "\\(")
        .replace(")", "\\)");
    if ($(".ui-autocomplete li:textEquals('" + val + "')").size() == 0) {
        $(this).val('');
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using an Ajax update panel and have recently added ASP.NET tracing code to
Update Added jsfiddle - see bottom of post I currently have a function that
I have created a new WPF application and added an event handler for Loaded
There're files/folders that were deleted and then re-added to the repository. svn update >
We've noticed that when checking in updates, our .DFM files have added ExplicitWidth and
I have a python script that takes input using a pattern like this: 1**
Update: Added Schema to the bottom... I have a table of contracts: tbl_contract And
I have some Perl code that translates new-lines and line-feeds to a normalized form.
I got a web application using the spring-security framework. I setted up a database
EDIT: Modified title and added update. UPDATE : We no longer believe this is

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.