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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:37:37+00:00 2026-06-17T05:37:37+00:00

The js below reveals a div based on the amount(size) of checkboxes vselected and

  • 0

The js below reveals a div based on the amount(size) of checkboxes vselected and it works fine. The checkboxes themselves are consecutive dates. What I need is to make sure that the dates selected are in consecutive order – ie 07/04, 07/05, 07/06 e.t.c. If the dates are not in consecutive order then the div does not reveal(show).

$('input[type=checkbox]').change(function(){
   if($('input:checked').size() > 4){
     $("#hideocrp").show();   
   }
   else {
     $('#hideocrp').hide()   
   }
});
  • 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-17T05:37:38+00:00Added an answer on June 17, 2026 at 5:37 am

    You can use the following code to achieve your goals:

    var start = false;
    var checkstart = false;
    $('#hideocrp').hide();
    $('input[type=checkbox]').change(function () {
      checkstart = false;
      start = false;
      $('input[type=checkbox]').each(function () {
        if ($(this).is(":checked")) {
          var index = $(this).index("input[type=checkbox]");
          if (start == false) {
            start = index + 1;
          }
          if (index == start - 1) {
            start = start + 1;
            checkstart++;
          } else {
            checkstart = false;
            return false;
          }
        }
      });
      if (checkstart > 3) {
        $("#hideocrp").show();
      } else {
        $('#hideocrp').hide();
      }
    });
    

    Live demo | Demo source

    Edit:
    Try using this code to do a relaxed search of a consecutive checkbox match.

    var start = false;
    var checkstart = false;
    $('#hideocrp').hide();
    $('input[type=checkbox]').change(function () {
      checkstart = 0;
      start = false;
      $('input[type=checkbox]').each(function () {
        if ($(this).is(":checked")) {
          var index = $(this).index("input[type=checkbox]");
          if (index == 0) {
            start = index+1;
          }
          if (index == start+1) {
            start = start + 1;
            checkstart++;
          } else {
            if (checkstart < 4) {
              checkstart = 1;
              start = index;
            } else {
              return false;
            }
          }
        }
      });
      if (checkstart > 3) {
        $("#hideocrp").show();
      } else {
        $('#hideocrp').hide();
      }
    });
    

    Live demo | Demo source

    Edit2:

    To solve your second issue, just use

    $(document).ready(function() {
      $('input[type=checkbox]').trigger("change");
    });
    

    Demo | Source

    To test against

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

Sidebar

Related Questions

The following code reveals a div on a keypress event of '?' (191). Works
Below is my form. Using jQuery I load a <select> element based on value
Below code not work, but it's work fine for jsf1.2. Now the framework is
Below, I want div A to act as a two column layout for it's
I'm looking detect when a div with class '.selected' is below the bottom of
Trying to create a div that is revealed below a link that slides to
Below is code to an inherited ComboBox. The issue is that the ComboBox is
Below is the code from internalRegister method of GCMRegistrar class static void internalRegister(Context context,
below is the code to download a txt file from internet approx 9000 lines
Below is my main activity file. I am stuck with the bottom area (commented

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.