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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T21:43:54+00:00 2026-05-12T21:43:54+00:00

I have a form that has many checkboxes (too many for it to make

  • 0

I have a form that has many checkboxes (too many for it to make sense to use their own rules), and I need to use the jQuery Validation Plugin to make sure at least one of them is selected. They all have different names, so most of the solutions I’ve found so far by Googling don’t work for me.

However, I came across this post, which I tweaked a bit to make this extension method:

// method for checking out checkboxes for the form validation
$.validator.methods.checkboxes_checked = function(value,element,param) {
   return ($('#signup #checkboxes input[type=checkbox]:checked').length > 0);
}

… which returns true or false depending if there are any of the checkboxes selected. I don’t want to use the method from the above post verbatim, since that would require making separate rules for each checkbox, and as I have a lot of them (20+), that doesn’t make much sense to me.

My only issue is that I don’t know how to wire this into my validation call, since I don’t have a “single” element on the page to tie it too (as in, all my other validation rules are tied to a specific single element, whereas my extension method above would be–in essence–tied to 20+ elements). Here’s how my validation call looks now:

// validate the form
$('#signup').validate({
   rules: {
      'bedrooms': { required: true },
      'maxrent': { required: true },
      'term': { required: true },
      'movedate': { required: true },
      'firstname': { required: true, minlength: 2 },
      'lastname': { required: true, minlength: 1, maxlength: 1 },
      'email': { required: true, email: true },
      'day_telephone': { required: true, digits: true, minlength: 10, maxlength: 10 }
   },
   errorPlacement: function(error, element) { error.css('display','none'); },
   highlight: function(element, errorClass) { 
      $(element).fadeOut(function() { $(element).fadeIn(); });
      $('label[for='+$(element).attr('name')+']').css('color','red');
   },
   unhighlight: function(element, errorClass) { $('label[for='+$(element).attr('name')+']').css('color','black'); },
   onkeyup: false
});

I want, basically, for the form itself to check (using the jQuery Validation Plugin) if my extension method returns true before submitting. How can I add this in?

  • 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-12T21:43:54+00:00Added an answer on May 12, 2026 at 9:43 pm

    I don’t know how your formular looks and where you want your error messages, but have you tried adding a custom validation method?

    $.validator.addMethod("checkboxes", function(value, element) {
        return $('input[type=checkbox]:checked').length > 0;
    }
    

    And then adding it as a rule for just one of your checkboxes:

    rules: {
        'idofacheckbox' : { checkboxes: true }
    }
    

    This one checkbox will then be valid if at least one checkbox is selected, or invalid when none are.

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

Sidebar

Related Questions

I have a workbook that has many checkboxes (form control) on one tab. I
I have a form that has many dynamically generated checkboxes. At runtime, how can
I have a form on the page. It has too many things like checkboxes
I have a form that has many long-methods. My quest is: What is the
I have a form that has a group of 3 text_fields. I need two
I have a event model that has many invitations. Invitations are setup through checkboxes
i have a form that has many input fields. some fields of them are
I have a Page (form) that has many UserControls on it, and I'm trying
I have a form that has label values that I would like to pass
I have a form that has 8 columns and a variable number of rows

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.