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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T20:12:12+00:00 2026-05-20T20:12:12+00:00

My question is very similar to jQuery Validation using the class instead of the

  • 0

My question is very similar to jQuery Validation using the class instead of the name value1. I want to validate a checkbox group, such that at least one needs to be checked. By default, both checkboxes are checked, but I want to ensure the user doesn’t uncheck both. The checkboxes are

    <div>
    <input type="checkbox" class="channel" name="web" checked />
    <label for="web" class="check">Web</label>
    <input type="checkbox" class="channel" name="mobile" checked />
    <label for="mobile" class="check">Mobile</label>
    </div>

The jquery I have is:

$("#searchForm").validate({
    rules:{
            ...
            ...
            ...
    }
});

$(".channel").rules("add", {  
    required: true, 
     minlength: 1

});

However, this doesn’t work quite as expected. If I check neither of the boxes or only the second one (mobile), the form won’t submit and I get an error message on the first one. What am I doing wrong?

  • 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-20T20:12:13+00:00Added an answer on May 20, 2026 at 8:12 pm

    I’m not sure if I’d use jQuery Validation for something like this, but if you just want to make sure that there is at least one checked checkbox in any group (whether that be class, or any other attribute), you can just check the length of any proper selector.

    if ($('.channel:checked').length == 0) {
        // validation fails
    }
    

    EDIT

    Without using Validation, you can stop the submit by doing something like:

    $('form').submit(function(e){
        if ($('.channel:checked').length == 0) {
            // validation fails, so stop submit
            e.preventDefault();
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What I am trying to do is very similar to this question: Using jQuery
My question is very similar to Trim text to 340 chars but in jQuery
This question is very similar to SQL Server 2005: T-SQL to temporarily disable a
Liu Chang asked a very similar question to this one here, Linux equivalent of
There is a very similar question already. One of the solutions uses code like
Very similar to this question , except for Java. What is the recommended way
I posted another question on a very similar topic, but turned out to be
This is very similar to a question I asked the other day but my
This is very similar to a question I asked the other day but my
This question was very helpful, however I have a list control in my report,

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.