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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:37:50+00:00 2026-06-15T14:37:50+00:00

Is it possible to limit a user’s selection to the predefined data-source items for

  • 0

Is it possible to limit a user’s selection to the predefined data-source items for a Bootstrap Typeahead item? So if the user types something that is not in the data-source, a message is be displayed notifying them as such?

Here’s the demo: http://cruiseoutlook.com/test

  • 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-06-15T14:37:51+00:00Added an answer on June 15, 2026 at 2:37 pm

    If I understand, when the typeahead component loses the focus, the user should be alerted that its input is invalid if it is not in the list?

    The code will thus be something like this :

    var myData = [...]; // This array will contain all your possible data for the typeahead
    
    $("#my-type-ahead").typeahead({source : myData})
                       .blur(validateSelection);
    
    function validateSelection() {
        if(source.indexOf($(this).val()) === -1) 
            alert('Error : element not in list!');
    }
    

    Just be careful about the fact that indexOf is not implemented in IE6-8. But shims can be found, for example : Best way to find if an item is in a JavaScript array? .

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

Sidebar

Related Questions

Is it possible to get all videos that a user uploaded on YouTube (without
Does anyone know if it is possible to limit how the user resizes a
Is this possible? I would like to have a limit for a user, lets
Just wondering if it's possible to limit a user to drawing only one rectangle
What is the best way to limit the amount of text that a user
Possible Duplicate: Limit jvm process memory on ubuntu In my application I'm uploading documents
Possible Duplicate: Limit file format when using <input type=file>? I need to use the
Is it possible to limit the number of JMS receiver instances to a single
I was wondering whether it is possible to limit the number of characters we
I'm wondering how to set the max possible time limit for a php page,

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.