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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:42:23+00:00 2026-06-07T18:42:23+00:00

I am using a jQuery script and the main part is below. It allows

  • 0

I am using a jQuery script and the main part is below. It allows me to select up to 4 items. Until there are 5 selections made, there is an error message.

How can I change this so that the error message appears if the choices are less than 2 and more than 5, and the success message is shown when the choices are between them?

if ($(this).multiselect("widget").find("input:checked").length > 5) {
    warning.addClass("error").removeClass("success").html("You can only check two checkboxes!");
    return false;
} else {
    warning.addClass("success").removeClass("error").html("Check a few boxes.");
}
  • 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-07T18:42:25+00:00Added an answer on June 7, 2026 at 6:42 pm

    You can get the number of checked items in to a local variable and then use a compound if statement that does multiple comparisons on it:

    var checkedItemsLength = $(this).multiselect("widget").find("input:checked").length;
    if(checkItemsLength < 2 || checkItemsLength > 5 ) {
        warning.addClass("error").removeClass("success").html("You can only check two checkboxes!");
        return false;
    } else {
        warning.addClass("success").removeClass("error").html("Check a few boxes.");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the jQuery script listed bellow in order to select a few checkbox
I have made a simple chat script using jquery and AJAX but the huge
I am trying to find and replace html data using jquery. The jquery script
Dutch page containing DIV blocks which can be hidden using a jQuery script. If
Am creating a script using JQuery on an ASP.NET page. Have a JSON string
I'm trying to make simple script using jquery $post function to pass data to
I have created a dynamic list picker script using Jquery 1.3 and PHP that
I am using a bespoke JQuery/PHP script which parses a Flickr feed using SimpliePie
Im using jquery 1.3.2 and this is the code: <script type=text/javascript> //<![CDATA[ jQuery(function(){ jQuery('.news_bullet
I've been using jquery 1.3.2 to pull snippets of html (including script) from a

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.